i want to display grid inside another grid but when i do this my master grid data comes well but the child grid data comes two times and i don't know how it is happening.
below is my gridview :
<asp:GridView runat="server" ID="GrdAmMaster" AutoGenerateColumns="False" CssClass="fontstyleGrd"
BackColor="White" BorderColor="LightGray" BorderStyle="Solid" BorderWidth="1px"
CellPadding="1" Width="900px" AllowPaging="True" DataKeyNames="SrNo" ShowHeader="false">
<HeaderStyle BackColor="Black" ForeColor="#fcbf04" />
<Columns>
<asp:TemplateField HeaderText="View">
<ItemStyle Width="30px" />
<ItemTemplate>
<asp:LinkButton ID="lbRmView" Text="View" CommandArgument='<% # Eval("SrNo")%>' CommandName="View"
runat="server" CssClass="grdlink">
</asp:LinkButton>
</ItemTemplate>
</asp:TemplateField>
<%--<asp:TemplateField HeaderText="Sr.No.">
<ItemStyle Width="50px" HorizontalAlign="Center" />
<ItemTemplate>
<%#Container.DataItemIndex+1%>
</ItemTemplate>
</asp:TemplateField>--%>
<asp:BoundField HeaderText="Sr.No." DataField="SrNo" ItemStyle-Width="40px" ItemStyle-HorizontalAlign="Center"></asp:BoundField>
<asp:BoundField HeaderText="Activity Name" DataField="AmName" ItemStyle-Width="300px">
<ItemStyle Width="300px"></ItemStyle>
</asp:BoundField>
<asp:BoundField HeaderText="UOM" DataField="AmUOM" ItemStyle-Width="200px"></asp:BoundField>
<asp:TemplateField HeaderText="ManPower" ItemStyle-Width="200px">
<ItemTemplate>
<asp:Panel ID="pnlAmChild" runat="server">
<asp:GridView ID="GrdAmMasterChild" runat="server" Width="400px" ShowHeader="false" BorderWidth="0px">
<Columns>
<asp:TemplateField HeaderText="Sr.No.">
<ItemStyle Width="30px" HorizontalAlign="Center" />
<ItemTemplate>
<%#Container.DataItemIndex+1%>
</ItemTemplate>
</asp:TemplateField>
<asp:BoundField HeaderText="Designation" DataField="AmDesig" ItemStyle-Width="170px"></asp:BoundField>
<asp:BoundField HeaderText="Numbers" DataField="AmNumbers" ItemStyle-Width="100px"></asp:BoundField>
</Columns>
</asp:GridView>
</asp:Panel>
</ItemTemplate>
</asp:TemplateField>
</Columns>
<PagerStyle HorizontalAlign="Center" />
<RowStyle Width="100px" />
</asp:GridView>
and my code for display child and master grid data :
Protected Sub BindAmMasterGrid()
Try
ObjCls.LoadGrid(GrdAmMaster, "SELECT Distinct SrNo, AmName, AmUOM FROM BOQActivityMasterMst WHERE EmpSrNo = '" & Session("ESrNo") & "'", "BOQActivityMasterMst")
Catch ex As Exception
End Try
End Sub
Protected Sub GrdAmMaster_RowDataBound(sender As Object, e As GridViewRowEventArgs) Handles GrdAmMaster.RowDataBound
Try
If e.Row.RowType = DataControlRowType.DataRow Then
Dim SrNoC As String = GrdAmMaster.DataKeys(e.Row.RowIndex).Value.ToString()
Dim gvOrders As GridView = TryCast(e.Row.FindControl("GrdAmMasterChild"), GridView)
ObjCls.LoadGrid(gvOrders, "SELECT Distinct SrNo, (select DesName from DesigMst where SrNo = AmDesig) as AmDesig, AmNumbers from BOQActivityMasterDet where RefSrNo = " & SrNoC & " and EmpSrNo = '" & Session("ESrNo") & "' Order By SrNo", "BOQActivityMasterDet")
End If
Catch ex As Exception
End Try
End Sub
below is the result what i get:
Dropbox - Grid.png[
^]
What I have tried:
above is the code which i have tried but not get any perfect solution.