利用DataGrid的SelectedIndexChanged事件进行处理。先添加一个模板列,往里边放一个linkbutton.private void DataGrid1_SelectedIndexChanged(object sender, System.EventArgs e)
{
string id=((LinkButton)DataGrid1.SelectedItem.FindControl("LinkButton15")).Text;
}
{
string id=((LinkButton)DataGrid1.SelectedItem.FindControl("LinkButton15")).Text;
}
解决方案 »
- gridview分页设置好以后,希望只有一页的时候页显示分页栏怎么设置
- Gridview控件的使用,
- html标记<变成<的问题
- 10分---------------大特送 o(∩_∩)o
- 奇怪!我的提交按钮怎么每次都要按两下才会提交?
- TreeView后台创建的节点以TEXT的长度中间对齐,看上去怪怪的,如何作到左对齐呢?
- 急!项目做不下去了。关于DataGrid中某一列的值要做成下拉,并且数据从其它表取?救命!
- 有一个ascx控件,内有一按钮,请问该按钮的click事件如何被外部改变?
- table邦定的问题,急,在线等?
- SQL语句怎么出错了呢???
- 怎样在弹出的窗口关掉后,让原窗口刷新一次
- 大家好,怎么删除已上传完的文件?谢谢!
private void DataGrid1_ItemCommand(object source,System.Web.UI.WebControls.DataGridCommandEventArgs e)
{
if(e.CommandName=="Select")
{
int id=Convert.ToInt32(e.Item.Cells[0].Text);
f(id);
}
}
a.datagrid 双击行,单击行事件 如何做?
b.datagrid 中鼠标移动过后 行变色?
http://aspalliance.com/Colt/Articles/Article3.aspx1.可以隐藏一个buttoncolumn,然后绑定客户端onclick事件激发该行的隐藏按钮的服务器段click事件;
2.在ItemDataBound事 件中c#if(e.Item.ItemType==ListItemType.Item || e.Item.ItemType==ListItemType.AlternatingItem)
{
e.Item.Attributes.Add("onmouseover", "this.style.backgroundColor='#99cc00';this.style.color='buttontext';this.style.cursor='default';");
e.Item.Attributes.Add("onmouseout", "this.style.backgroundColor='';this.style.color='';");
}
vb.net If e.Item.ItemType <> ListItemType.Header And e.Item.ItemType <> ListItemType.Footer Then
Response.Write(Color.Beige.ToString())
e.Item.Attributes("id") = e.Item.ItemType.ToString() + e.Item.ItemIndex.ToString()
e.Item.Attributes.Add("OnMouseOut", "this.style.backgroundColor='';")
e.Item.Attributes.Add("OnMouseOver", "this.style.backgroundColor='#99cc00';this.style.color='buttontext';this.style.cursor='default';") End If
+");")
按照你的方法我已经试了,不行
f(int id)是定义在cs中的,不是javascript函数
可选择按扭只要单击就可以触发了,
我需要的是双击才能触发f(id)方法,
请大家再帮我想想其他方法
<script language="javascript">
<!--
function setValue()
{
window.document.form1.Isdbclick.value="true";
---Form 的 ID
window.document.form1.submit();
}
-->
</script><input type="hidden" name="Isdbclick" value="false">private void Page_Load(object sender, System.EventArgs e)
{
// 在此处放置用户代码以初始化页面
if (Page.IsPostBack)
{
if (Request.Form["Isdbclick"]!=null)
{
{
if (Request.Form["Isdbclick"].ToString()=="true")
{
f(1);
}
}
}
}public void f(int id)
{
...写你要做的事情就OK了,哈哈
}
这句话放在哪里啊?好像没地方放哦!
不过,再问你个问题:
我在dataGrid中放有1个摸板列,摸板列是一列按扭(id=btn),
我怎么样通过javascript来触发摸板列中的按扭(注意:是要通过javascirpt来触发)
我用过document.all.btn.click() 不行