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
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
}
}
精彩评论