Sign In| Join
Get Help:Ask a Question in our Forums|Report a Bug|More Help Resources
Last post Jun 15, 2012 04:32 AM by karthicks
Member
75 Points
178 Posts
Jun 15, 2012 03:28 AM|LINK
Hi,
I would like to know how to disable and enable checkbox in gridview
when one of the other column has "Yes" or "No" value. Eg.
S/N InvitationSent Delete
1 Yes (checkbox-disable)
2 No (checkbox-enable)
Please, can anyone give me any idea or hints for that how to do.
Thanks in advanced.
All-Star
31374 Points
5420 Posts
Jun 15, 2012 04:32 AM|LINK
hi, you can either do it using binding expression
<asp:TemplateField> <ItemTemplate> <asp:CheckBox ID="CheckBox1" runat="server" Enabled='<%# Eval("InvitationSent").ToString().Equals("No") %>' /> </ItemTemplate> </asp:TemplateField>
or in Grid RowDataBound event
protected void GridView1_RowDataBound(object sender, GridViewRowEventArgs e) { if (e.Row.RowType == DataControlRowType.DataRow) { (e.Row.FindControl("CheckBox1") as CheckBox).Enabled = (e.Row.DataItem as System.Data.DataRowView)["InvitationSent"].ToString().Equals("No"); } }
Junior1012
Member
75 Points
178 Posts
How to disable checkbox in gridview when one of the column value is "Yes"
Jun 15, 2012 03:28 AM|LINK
Hi,
I would like to know how to disable and enable checkbox in gridview
when one of the other column has "Yes" or "No" value. Eg.
S/N InvitationSent Delete
1 Yes (checkbox-disable)
2 No (checkbox-enable)
Please, can anyone give me any idea or hints for that how to do.
Thanks in advanced.
karthicks
All-Star
31374 Points
5420 Posts
Re: How to disable checkbox in gridview when one of the column value is "Yes"
Jun 15, 2012 04:32 AM|LINK
hi, you can either do it using binding expression
<asp:TemplateField> <ItemTemplate> <asp:CheckBox ID="CheckBox1" runat="server" Enabled='<%# Eval("InvitationSent").ToString().Equals("No") %>' /> </ItemTemplate> </asp:TemplateField>or in Grid RowDataBound event
protected void GridView1_RowDataBound(object sender, GridViewRowEventArgs e) { if (e.Row.RowType == DataControlRowType.DataRow) { (e.Row.FindControl("CheckBox1") as CheckBox).Enabled = (e.Row.DataItem as System.Data.DataRowView)["InvitationSent"].ToString().Equals("No"); } }Karthick S