<asp:GridView ID="gvAttributes" runat="server" AutoGenerateColumns="false" EnableModelValidation="True" CssClass="GridViewStyle" onrowdatabound="gvAttributes_RowDataBound"> <Columns> <asp:TemplateField HeaderText="Select"> <ItemTemplate> <asp:CheckBox ID="cbxAttributescheck" runat="server" Text='' <%# Eval("AttributeName") %> AutoPostBack="true" OnCheckedChanged="cbxAttributescheck_CheckedChanged"/> <asp:HiddenField ID="hdnAttributeValue" runat="server" Value='' <%# Eval("AttributeID") %>' /> <asp:Label ID="lblDelete" runat="server" Text='' <%# Eval("AttributeID") %>' Visible="false"></asp:Label> </ItemTemplate> </asp:TemplateField> <asp:TemplateField HeaderText="Data Type" > <ItemTemplate> <asp:DropDownList ID="ddlAttributesDataType" runat="server"> </asp:DropDownList> <asp:RequiredFieldValidator ID="rfvAttributeType" runat="server" ErrorMessage="*" Enabled="false" ControlToValidate="ddlAttributesDataType" InitialValue="0"> </asp:RequiredFieldValidator> </ItemTemplate> </asp:TemplateField> <asp:TemplateField HeaderText="Allow Nulls" > <ItemTemplate> <asp:CheckBox ID="cbxAttributesisnull" runat="server" /> </ItemTemplate> </asp:TemplateField> </Columns> </asp:GridView>
protected void cbxAttributescheck_CheckedChanged(object sender, EventArgs e) { CheckBox cbx = (CheckBox)sender; string CurrentCbxId = ((CheckBox)sender).ClientID; foreach (GridViewRow Row in gvAttributes.Rows) { if (((CheckBox)Row.FindControl("cbxAttributescheck")).ClientID.Equals(CurrentCbxId) && cbx.Checked) { RequiredFieldValidator rfvAttributeType = (RequiredFieldValidator)Row.FindControl("rfvAttributeType"); rfvAttributeType.Enabled = true; } } }
var
This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)