<asp:GridView ID="lvMainModule" GridLines="None" CssClass="gridviewShow" AutoGenerateColumns="false"
                                                    DataKeyNames="LinkMasterId"  OnRowDataBound="lvMainModule_ItemDataBound" runat="server">
                                                    <Columns>
                                                        <asp:TemplateField>
                                                            <ItemTemplate>
                                                                <asp:Label ID="ModuleNameLabel" runat="server" Font-Bold="true" Text='<%# Eval("LinkMasterType") %>' />
                                                                <asp:Label ID="LinkMasterId" runat="server" Visible="false" Text='<%# Eval("LinkMasterId") %>' />
                                                                <br />
                                                                <br />
                                                                <asp:GridView ID="lvSubModule" GridLines="None" OnRowEditing ="lvSubModule_RowEditing" CssClass="gridviewShow" AutoGenerateColumns="false"
                                                                    ShowHeader="false" DataKeyNames="Id" runat="server">
                                                                    <Columns>
                                                                     <asp:CommandField ShowDeleteButton="True" ShowEditButton="True" />
                                                                        <asp:TemplateField>
                                                                            <ItemTemplate>
                                                                                <asp:HyperLink name='<%# Eval("Link_ScrollId") %>' ID="subLink_Name" Text='<%# Eval("Link_Name") %>'
                                                                                    NavigateUrl='<%# Eval("Link_Url") %>' runat="server"></asp:HyperLink>
                                                                                <asp:Label ID="lblSubModuleCode" runat="server" Visible="false" Text='<%# Eval("Id")%>'></asp:Label>
                                                                                <br />
                                                                            </ItemTemplate>
                                                                            <EditItemTemplate>
                                                                                <asp:TextBox ID="txtLink_Name" runat="server" Text='<%#Bind("Link_Name") %>'>
                                                                                </asp:TextBox>
                                                                            </EditItemTemplate>
                                                                        </asp:TemplateField>
                                                                    </Columns>
                                                                </asp:GridView>
                                                            </ItemTemplate>
                                                        </asp:TemplateField>
                                                    </Columns>
                                                </asp:GridView>

Code Behind:-

 protected void lvSubModule_RowEditing(object sender, GridViewEditEventArgs e)
    {
        //GridView lvSub = (GridView)lvMainModule.Rows[e.NewEditIndex].FindControl("lvSubModule");

        //if (lvSub != null)
        //{
        //    lvSub.EditIndex = e.NewEditIndex;

        //}
        GridView gv = sender as GridView;
        gv.EditIndex = e.NewEditIndex;
        GetMainModules();

    }
Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.