开发者

Checkbox in gridview control

开发者 https://www.devze.com 2023-04-04 23:19 出处:网络
I am using gridview to display labels, checkboxes, dropdown lists and textboxes (see image) i would like that some fields are hidden when the checkbox is unchecked and as soon as i check it, those hi

I am using gridview to display labels, checkboxes, dropdown lists and textboxes

(see image) i would like that some fields are hidden when the checkbox is unchecked and as soon as i check it, those hidden fields appear.(the fields to be hidden are the reason a开发者_高级运维nd the comments)

normally i assume i would use selectedindexchanged but since this is in a gridview i am not sure what i should do

Checkbox in gridview control

Thanks


Make use of OnCheckedChanged of check box

protected void chkbox_OnCheckedChanged(object sender, EventArgs e)
{
      int selRowIndex = ((GridViewRow)(((CheckBox)sender).Parent.Parent)).RowIndex;
      CheckBox cb = (CheckBox)gridView.Rows[selRowIndex].FindControl("chkbox");

      if (cb.Checked)
      {
             // Find other control using FindControl and check the
      }
}
0

精彩评论

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