怎么获取GridView中某一行某列的值 我点击GridView中某行的查看按钮 就获取这行的信息 请问怎么获取啊 ??? 解决方案 » 免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货 一般是先选中行,然后对行进行操作。有许多方法可以选择。http://topic.csdn.net/u/20090819/14/3c30eda5-1c6d-498a-a636-be95ad5bd894.html参考 i为索引,比如要获取第二行,第三列的值gvTest.Rows[1].Cells[2].Text;因为是索引所以 数据位置要 -1,第二行,索引就是1,第三列,索引就是2 //GridView綁定行事件 protected void gvArea_RowDataBound(object sender, GridViewRowEventArgs e) { if (e.Row.RowType == DataControlRowType.DataRow) { e.Row.Cells[1].Attributes.Add("onclick", "javascript:show(" + e.Row.RowIndex.ToString() + ")"); e.Row.Cells[2].Attributes.Add("onclick", "javascript:show(" + e.Row.RowIndex.ToString() + ")"); e.Row.Cells[3].Attributes.Add("onclick", "javascript:show(" + e.Row.RowIndex.ToString() + ")"); e.Row.Cells[4].Attributes.Add("onclick", "javascript:show(" + e.Row.RowIndex.ToString() + ")");//#C7E1F8 e.Row.Attributes.Add("onmouseover", "c=this.style.backgroundColor;this.style.backgroundColor='#bdddfc'"); e.Row.Attributes.Add("onmouseout", "this.style.backgroundColor=c"); } }这里你可以填入主键,然后通过JS事件传给需要的页面 或 其他地方有了主键 还有什么拿不到的??呵呵 看你代码如何定义了:常用三种用法:1、若在DATAKEYSNAME里定义了该列。则可THIS.Gridview1.datakeys[e.rowindex][索引].Text.2、THIS.GRIDVIEW1.rows[e.rowindex].cells[你想要的列对应的索引].Text.3、若对应的列是模版列,可((控件类型)THIS.GRIDVIEW1.rows[e.rowindex].FINDCONTROL("列对应的控件ID")).Text/value(HTML控件) gvStoneStock.Rows[i].Cells[i].Text 可以的 菜鸟 问个比较弱智的问题 关于ASP.NET MVC环境配置的问题 这个两个方法功能是什么,不要行吗? IgnoreRoute MapRoute checkboxlist 样式 这是要搞哪样啊…… URL重写 无法打开登录 'SBW' 中请求的数据库。登录失败 最简单的问题,2005怎么建立个网站站点,最好有详细步骤 百分求助交流学习 c#动态创建oracle存储过程(急),请高手解答 如何弹出确认删除对话框(Asp.Net2 的C#编程) web项目调试时网页一直转圈圈,断网就啥都好了 急需一个sql2005个人版下载地址 数据的前台绑定与后台绑定各自优缺点
有许多方法可以选择。http://topic.csdn.net/u/20090819/14/3c30eda5-1c6d-498a-a636-be95ad5bd894.html
参考
protected void gvArea_RowDataBound(object sender, GridViewRowEventArgs e)
{
if (e.Row.RowType == DataControlRowType.DataRow)
{
e.Row.Cells[1].Attributes.Add("onclick", "javascript:show(" + e.Row.RowIndex.ToString() + ")");
e.Row.Cells[2].Attributes.Add("onclick", "javascript:show(" + e.Row.RowIndex.ToString() + ")");
e.Row.Cells[3].Attributes.Add("onclick", "javascript:show(" + e.Row.RowIndex.ToString() + ")");
e.Row.Cells[4].Attributes.Add("onclick", "javascript:show(" + e.Row.RowIndex.ToString() + ")");//#C7E1F8
e.Row.Attributes.Add("onmouseover", "c=this.style.backgroundColor;this.style.backgroundColor='#bdddfc'");
e.Row.Attributes.Add("onmouseout", "this.style.backgroundColor=c");
}
}这里你可以填入主键,然后通过JS事件传给需要的页面 或 其他地方有了主键 还有什么拿不到的??呵呵
常用三种用法:
1、若在DATAKEYSNAME里定义了该列。则可THIS.Gridview1.datakeys[e.rowindex][索引].Text.
2、THIS.GRIDVIEW1.rows[e.rowindex].cells[你想要的列对应的索引].Text.
3、若对应的列是模版列,可((控件类型)THIS.GRIDVIEW1.rows[e.rowindex].FINDCONTROL("列对应的控件ID")).Text/value(HTML控件)