开发者

Usage of checkbox to retrive the multiple dataitems in Datagrid inASP.NET C#

开发者 https://www.devze.com 2023-03-11 20:46 出处:网络
protected void Button1_Cl开发者_高级运维ick(object sender, EventArgs e) { foreach (DataGridItem di in GridView1.Items)
     protected void Button1_Cl开发者_高级运维ick(object sender, EventArgs e)
  {
   foreach (DataGridItem di in GridView1.Items)
   {
       HtmlInputCheckBox chkBx = (HtmlInputCheckBox)di.FindControl("CheckBox1");
       if (chkBx != null && chkBx.Checked)
       {
          //What should I write to get the Items of that checked row.

       }
     }

   }

Help me how to retrieve the row items of the each checked row.

I tried like this but its not appending anything to the label

      foreach (GridViewRow di in GridView1.Rows)
   {
       HtmlInputCheckBox chkBx = (HtmlInputCheckBox)di.FindControl("CheckBox1");
       if ( chkBx != null && chkBx.Checked)
       {
           FID[j] += di.Cells[2].Text;
           j++;

           Label1.Text += di.Cells[2].Text;

            }

       }


It should Rows instead Items

foreach (GridViewRow di in GridView1.Rows)
{
   HtmlInputCheckBox chkBx = (HtmlInputCheckBox)di.FindControl("CheckBox1");
   if (chkBx != null && chkBx.Checked)
   {
      //What should I write to get the Items of that checked row.

   }
 }
0

精彩评论

暂无评论...
验证码 换一张
取 消