This is my .aspx Code

<asp:GridView ID="gv_Child" runat="server" Width="50%" CssClass="Nested_ChildGrid about-team-right"
                AutoGenerateColumns="false" DataKeyNames="unitId">
                <Columns>
                    <asp:TemplateField HeaderText="Is Stored">
                        <ItemTemplate>
                            <asp:CheckBox ID="chkIsStored" runat="server" Checked="false" OnCheckedChanged="chkIsStored_CheckedChanged" AutoPostBack="true" />
                            <asp:HiddenField ID="hfRcvItemstoreLocationIDDetails" runat="server"></asp:HiddenField>
                        </ItemTemplate>
                    </asp:TemplateField>
                    <asp:BoundField DataField="StoreLocationId" ItemStyle-CssClass="hiddencol" HeaderStyle-CssClass="hiddencol" />
                    <asp:BoundField DataField="StoreId" ItemStyle-CssClass="hiddencol" HeaderStyle-CssClass="hiddencol" />
                    <asp:BoundField DataField="BuildingName" HeaderText="Building Name" ControlStyle-Font-Size="Small" />
                    <asp:BoundField DataField="FloorName" HeaderText="Floor Name" ControlStyle-Font-Size="Small" />
                    <asp:BoundField DataField="Location" HeaderText="Location" ControlStyle-Font-Size="Small" />
                    <asp:BoundField DataField="StoreName" HeaderText="Store Name" ControlStyle-Font-Size="Small" />
                    <asp:TemplateField HeaderText="Store Qty">
                        <ItemTemplate>
                            <asp:TextBox ID="txtStore_Qty" runat="server" CssClass="TextBox" Width="40px"></asp:TextBox>

                        </ItemTemplate>
                    </asp:TemplateField>
                </Columns>
                <HeaderStyle BackColor="#4D92C1" ForeColor="White" />
            </asp:GridView>

and code behind for checkbox

protected void chkIsStored_CheckedChanged(object sender, EventArgs e)
    {
        GridViewRow Row = ((GridViewRow)((Control)sender).Parent.Parent);
        int i = Row.RowIndex;
        i++;

         CheckBox cb = (CheckBox)sender;
        GridViewRow row = (GridViewRow)cb.NamingContainer;
        TextBox txtStore_Qty = row.FindControl("txtStore_Qty") as TextBox;


        if (cb.Checked)
        {

            txtStore_Qty.Enabled = true;
        }
        else
        {
            txtStore_Qty.Enabled = false;

        }
    }

Related posts

Recent Viewed