assume you are using server checkbox controls, (otherwise, you only need to use Request.Form["CheckboxName"] to get a list of checked values)foreach (DataGridItem dgi in DataGrid1.Items)
{
CheckBox cb = (CheckBox)dgi.FindControl("CheckBoxID");
if (cb.Checked)
{
//.....
}
}//在第一个页面中datagrid分页后又回到以前的页面时,以前选中的checkbox会自动恢复到未选状态,这一问题如何解决you need to remember the checked states and apply them when you bind the DataGrid
...<asp:CheckBox id="CheckBoxID" runat="server" Checked='<%# DataBinder.Eval(Container.DataItem,"Checked") %>' />
{
CheckBox cb = (CheckBox)dgi.FindControl("CheckBoxID");
if (cb.Checked)
{
//.....
}
}//在第一个页面中datagrid分页后又回到以前的页面时,以前选中的checkbox会自动恢复到未选状态,这一问题如何解决you need to remember the checked states and apply them when you bind the DataGrid
...<asp:CheckBox id="CheckBoxID" runat="server" Checked='<%# DataBinder.Eval(Container.DataItem,"Checked") %>' />
解决方案 »
免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货