-1

我在每一行都有一个带有复选框的 radgride。我希望当我单击按钮时,它会检查检查的每一行的 id,并将其放入变量中。我知道 gridview 的此代码,但我不知道 radgrid 的此代码的等效项

foreach (GridViewRow rw in grid1.Rows)
      {
          CheckBox chkBx = (CheckBox)rw.FindControl("Check");
          if (chkBx != null && chkBx.Checked)
          {


              id= grid1.Rows[0].Cells[3].Text.ToString();


          }
      }
4

2 回答 2

1
if (RadGrid1.Items.Count > 0)
 {
   foreach (GridDataItem item in RadGrid1.Items)//loops through each grid row
    {
       CheckBox chkBx = (CheckBox)rw.FindControl("Check");
       if (chkBx != null && chkBx.Checked)
        {
          //string v= item["ColumnUniqueName"].Text;
            string v= item.Cells[3].Text; //accessing cell using its ColumnUniqueName
        } 
    }
 }

有关 Radgrid 行和单元格访问的更多信息,请查看http://www.telerik.com/help/aspnet-ajax/grid-accessing-cells-and-rows.html

于 2013-01-19T05:48:31.810 回答
0

试试这个:http ://www.telerik.com/community/forums/aspnet-ajax/grid/loop-through-radgrid.aspx

foreach(GridItem rw in grid1.Items)
{
    CheckBox chkBx = rw.FindControl("Check") as CheckBox ;
    if (chkBx != null && chkBx.Checked)
    {
        string id = rw.Cells[3].Text;
    }
}
于 2013-01-19T05:46:46.807 回答