GridView问题?鼠标点到GridView的某一行,如何知道点到的是第几行? GridView问题?鼠标点到GridView的某一行,如何知道点到的是第几行?解决速结贴.谢谢诶. 解决方案 » 免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货 aspx 页用<%#Container.DataItemIndex %>cs页用 .SelectedIndex protected void GridView1_RowDataBound(object sender, GridViewRowEventArgs e) { if (e.Row.RowType == DataControlRowType.DataRow) { e.Row.Attributes["onmouseover"] = "this.style.color='Red';"; e.Row.Attributes["onmouseout"] = "this.style.color='Black';"; e.Row.Attributes["onclick"] = string.Format("alert('{0}')", e.Row.RowIndex); } } protected void GV_Item_SelectedIndexChanged(object sender, EventArgs e) { int value = GV_Item.SelectedIndex; } 支持。值得注意的是:e.Row.RowIndex是从0开始,实际行号要加1。不过我一般在用GridView显示数据的时候都会将第一行显示序号,也就是行号了。在上面的函数中添加如下代码:if (e.Row.RowIndex > -1) { int id = e.Row.RowIndex + 1; e.Row.Cells[0].Text = id.ToString(); } 来说说server-push吧 唉,这么大个人了,下了个源码居然无从下手。。 Jquery 单选按钮 不可选 asp.net from提交在火狐里没有效果 不知道的问题 请问CheckListBox的SelectedIndexChanged事件中怎么取当前选择项的index与其它信息 问大家一个关于控件使用的问题 xml数据导入sqlserver2005 急!!!请教一个页面存在多个用户控件的数据验证问题? 程序整合的问题? 两个存储过程的比较 什么是表单验证
cs页用
.SelectedIndex
protected void GridView1_RowDataBound(object sender, GridViewRowEventArgs e)
{
if (e.Row.RowType == DataControlRowType.DataRow)
{
e.Row.Attributes["onmouseover"] = "this.style.color='Red';";
e.Row.Attributes["onmouseout"] = "this.style.color='Black';";
e.Row.Attributes["onclick"] = string.Format("alert('{0}')", e.Row.RowIndex);
}
}
protected void GV_Item_SelectedIndexChanged(object sender, EventArgs e)
{
int value = GV_Item.SelectedIndex;
}
支持。
值得注意的是:e.Row.RowIndex是从0开始,实际行号要加1。
不过我一般在用GridView显示数据的时候都会将第一行显示序号,也就是行号了。在上面的函数中添加如下代码:
if (e.Row.RowIndex > -1)
{
int id = e.Row.RowIndex + 1;
e.Row.Cells[0].Text = id.ToString();
}