jeudi 6 juillet 2017

Operation with checkbox in a nested gridview

This is the design for the gridview.

<asp:GridView ID="gmainrole" runat="server" OnRowDataBound="gmainrole_RowDataBound">
            <Columns>
                <asp:TemplateField>
                    <ItemTemplate>
                        <input type="checkbox" id="chkavail" runat="server" checked='<%#Eval("checkstatus") %>' />
                        &nbsp;
                        <asp:Literal ID="litstate" runat="server" Text='<%#Eval("areaname") %>'></asp:Literal>
                        <asp:Literal ID="lituserrole" runat="server" Text='<%#Eval("nid") %>' Visible="false"></asp:Literal>
                        <asp:GridView ID="subrole" runat="server" AutoGenerateColumns="false" OnRowDataBound="subrole_RowDataBound">
                            <Columns>
                                <asp:TemplateField>
                                    <ItemTemplate>
                                        <asp:CheckBox ID="chk1vail" runat="server" Checked='<%#Eval("checkstatus") %>' />
                                        <asp:Literal ID="litstate" runat="server" Text='<%#Eval("areaname") %>'></asp:Literal>
                                        <asp:Literal ID="lituserrole" runat="server" Text='<%#Eval("nid") %>' Visible="false"></asp:Literal>
                                        <asp:DataList ID="glastrole" runat="server" GridLines="None" AutoGenerateColumns="false" OnItemDataBound="glastrole_ItemDataBound">
                                            <ItemTemplate>
                                                <div>
                                                    <asp:CheckBoxList runat="server" ID="chklastrole">
                                                    </asp:CheckBoxList>
                                                    &nbsp;
                                                                                                    <asp:Literal ID="Literal1" runat="server" Text='<%#Eval("areaname") %>'></asp:Literal>
                                                    <asp:Literal ID="litlast" runat="server" Text='<%#Eval("nid") %>' Visible="false"></asp:Literal>
                                                    <asp:DataList ID="ecounter" runat="server" GridLines="None" AutoGenerateColumns="false">
                                                        <ItemTemplate>
                                                            <asp:CheckBoxList runat="server" ID="chklastrole">
                                                            </asp:CheckBoxList>

                                                            &nbsp;
                                                                                                    <asp:Literal ID="Literal11" runat="server" Text='<%#Eval("areaname") %>'></asp:Literal>
                                                            <asp:Literal ID="litlast1" runat="server" Text='<%#Eval("nid") %>' Visible="false"></asp:Literal>
                                                        </ItemTemplate>
                                                    </asp:DataList>
                                                </div>
                                            </ItemTemplate>
                                        </asp:DataList>
                                        </table>
                                    </ItemTemplate>
                                </asp:TemplateField>
                            </Columns>
                        </asp:GridView>
                        </td>
                            </tr>
                        </table>
                    </ItemTemplate>
                </asp:TemplateField>
            </Columns>
        </asp:GridView>

This gridview is a four level nested gridview where the lower two levels are datalists and upper two levels are gridviews. I want that when a user checks a checkbox inside the second gridview named subrole(level 2), all the subsequent checkboxes in the datalist glastrole(level 3) and datalist ecounter(level 4) get their checkboxes checked for that particular level 2 checkbox. I would give you the code that I have tried till now but the fact is I don't even know how to approach this problem. Please help!

Aucun commentaire:

Enregistrer un commentaire