首页 新闻 会员 周边

asp.net gridview获取一行中所有字段的问题

0
悬赏园豆:10 [已关闭问题] 关闭于 2011-08-26 21:01

需求:有一个gridview,没有模板列,只有Boundfile列,

就是单击一行中的任意一点,就能获取这行中的所有字段!谢谢

Peter.zhong的主页 Peter.zhong | 初学一级 | 园豆:117
提问于:2011-08-21 21:58
< >
分享
所有回答(3)
0

在RowDataBound里面。 e.Row.DataItem 就是你指定数据源的子数据类型。

新瓶老酒 | 园豆:181 (初学一级) | 2011-08-22 09:31
0

添加一个CommandField的“选择”,在RowDataBound事件中添加

 if (e.Row.RowType == DataControlRowType.DataRow)
        {
            e.Row.Attributes["OnClick"] = ClientScript.GetPostBackEventReference(e.Row.Parent.Parent, "Select$" + e.Row.RowIndex);
            e.Row.Attributes.Add("onmouseover", "currentcolor=this.style.backgroundColor;this.style.backgroundColor='#ccddff'");
            e.Row.Attributes.Add("onmouseout", "this.style.backgroundColor=currentcolor;");
        }

xuebingz | 园豆:143 (初学一级) | 2011-08-22 10:57
1

e.Row.DataItem转换为数据库的对象。然后随便你怎么玩了

梦怀天 | 园豆:222 (菜鸟二级) | 2011-08-22 11:18
清除回答草稿
   您需要登录以后才能回答,未注册用户请先注册