You must Sign In to post a response.
  • Category: ASP.NET

    Bind a grid inside a grid?

    Can someone tell me the step by step procedure to bind a gridview inside a gridview?
    I just want to Show Some related data to be bind to the inside grid respected to the outside grid's specific column Value.
  • #764392
    Hai Manoj,
    This is very primary stuff where you need to bind a grid inside another grid based on the main grid data.
    You can get many example in DNS as well.
    Below I am providing few links, you can go through with them:

    Hope it will be helpful to you.

    Pawan Awasthi(DNS MVM)
    +91 8123489140 (whatsApp), +60 14365 1476(Malaysia)

  • #764400
    There are number of example found for nested gridview, you need to simply you can add child gridview in ItemTemplate and you can get your result, with the help of 'Row.FindControl' method you can get its object and can get its rows/col info.
    see some below URL's

    Editor, DotNetSpider MVM
    Microsoft MVP 2014 [ASP.NET/IIS]

  • #764415
    Hi Manoj,

    while implement nested gridview you need parent and child relation for the records, based on parent record you should bind your child record, for that you need to concentrate on design part also, in parent gridview one of the field(TemplateField) you should design your child gridview and on rowdatabound event of parent gridview you should bind the records of child gridview based on parent record.

    I wrote one article for the above requirement go through this, if you still having problem then please let us know.

    Give respect to your work, Instead of trying to impress your boss.

    Blog :

  • #764444
    You may use following code snippet to bind a grid inside another grid as guideline. You need to change according to your need

    <asp:GridView ID="GV1" runat="server" AutoGenerateColumns="False"
    AutoGenerateDeleteButton="True" AutoGenerateEditButton="True"
    onrowdeleting="GV1_RowDeleting" onrowediting="GV1_RowEditing"
    onrowupdating="GV1_RowUpdating" OnRowCommand="GV1_RowCommand">
    <asp:TemplateField HeaderText="Student Name">
    <asp:Label ID="lblID" runat="server" Text='<%#Eval("Student ID") %>'></asp:Label>
    <%--<asp:Label ID="Label1" runat="server" Text='<%# Container.DataItemIndex%>'>
    <asp:TemplateField HeaderText="A">
    <asp:Button ID="btnShow" runat="server" Text="Expand"
    CommandName="Show" CommandArgument='<%# Container.DataItemIndex%>' />

Sign In to post your comments