DataGrid行循环 [英] Datagrid Rows Loop
本文介绍了DataGrid行循环的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我试图采取 ID
DataGrid的每一行的 dgGrid
有选择的复选框和地点它变成一个数组 ruleids
。我抬头一看在线的例子,发现这个循环出现。
当我试图重构逻辑我得到这个错误:
System.Web.UI.WebControls不包含行定义
块引用>INT [] ruleids = NULL;
的foreach(在dgGrid.Rows GridViewRow GVR)
{
如果(((复选框)gvr.findcontrol(chkSelect))。经过==真)
{
ruleids.add(gvr.cells [ID]);
}
}
解决方案DataGrid不包含行的定义。取而代之行,它有项目。
因此,与Datagrid.items ...
尝试的foreach(在dgGrid.Items GridViewItem GVR)
{ //唧唧歪歪...
}希望这有助于你......
I am attempting to take the
id
of each row of the datagriddgGrid
that has a checkbox selected and place it into an arrayruleids
. I've looked up examples online and noticed that this loop comes up.when I attempted to reconstruct the logic I get this error:
System.Web.UI.WebControls does not contain a definition for Rows.
int[] ruleids = null; foreach (GridViewRow gvr in dgGrid.Rows) { if (((CheckBox)gvr.findcontrol("chkSelect")).Checked == true) { ruleids.add(gvr.cells["id"]); } }
解决方案Datagrid does not contain a definition for "rows". Instead of rows, it has "items".
So try with Datagrid.items...
foreach (GridViewItem gvr in dgGrid.Items) { //BLA BLA BLA... }
Hope this helps you...
这篇关于DataGrid行循环的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文