开发者

Checkbox in gridview control

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

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜