GridView获取选定字段的数据 [英] GridView get data of selected field
本文介绍了GridView获取选定字段的数据的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
伙计们.
我只想获取用户已选择的行的主键值.
我有一个按钮,用户可以单击它要将ID传递到新页面的按钮.
有什么办法可以取出数据?
我发现了gridview rows.cells [cell no];
但这不适用于隐藏的列.
我只想拥有分页排序功能,而不必在转发器中创建它们.
Hi guyz .
I just want to get the primary key value of the row that has been selected by user .
I have a button which the user can click upin which i want to pass the id to a new page.
is there any way to get the data out ?
I found gridview rows.cells[cell no];
but this doesnt work for hidden columns.
I just wanna have the paging sorting functionalities ,istead of having to create them in a repeater.
推荐答案
看看这个: ^ ].
嘿Navanit,
将Primarykey列名称分配给GridView的DatakeyName属性,然后在GridView的selectedIndexchanged事件上进行尝试
hey Navanit,
Assign Primarykey column name to DatakeyName property of GridView and try this on selectedIndexchanged event of GridView
int _gCode;
_gCode = GridView1.DataKeys[GridView1.SelectedIndex].Value.ToString();
或者您也可以使用它..
or u can use this also..
int j = GridView1.SelectedRow.RowIndex;
_gCode = Convert.ToInt32(GridView1.DataKeys[j].Value);
希望对您有帮助.
hope this help u.
这篇关于GridView获取选定字段的数据的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文