how to nested the gridview

Last post 12-18-2008 11:53 AM by bjcanada. 5 replies.

Sort Posts:

  • how to nested the gridview

    12-16-2008, 4:58 PM
    • Member
      8 point Member
    • bjcanada
    • Member since 06-17-2008, 5:12 PM
    • Posts 108

    Hi all,

    I need nested the gridview, make one gridview in another gridview.

    Can someone give me some suggestion?

     

     

    Thanks in advance!

  • Re: how to nested the gridview

    12-16-2008, 7:39 PM
    • Member
      204 point Member
    • cherishnews
    • Member since 10-24-2008, 7:51 AM
    • Posts 162

    Hi,

    Not sure which part you are stuck at. Maybe it will be better to specify your problem.

    But first of all, you can insert one more gridview in the main gridview through ItemTemplate.

    Make use of the RowDataBound event of the outer gridview to bind data to your inner gridview.

  • Re: how to nested the gridview

    12-17-2008, 4:00 AM
    • Participant
      1,070 point Participant
    • kuber.manral
    • Member since 02-27-2008, 5:20 AM
    • Posts 269

    bjcanada:
    I need nested the gridview, make one gridview in another gridview.

    Please check out these links:

    http://www.codeproject.com/KB/aspnet/SkinSample.aspx
    http://msdn.microsoft.com/en-us/library/aa992038(VS.80).aspx

    Please "Mark As Answer", if this post helps you.

     

     

    Thanks & Regards
    Kuber Singh Manral.
    MCTS [ASP.Net 2.0 Web Client Application]

    Please "Mark As Answer", if any Post helps you. It facilitates to find
    exact solution of the problem.
  • Re: how to nested the gridview

    12-17-2008, 2:48 PM
    • Member
      8 point Member
    • bjcanada
    • Member since 06-17-2008, 5:12 PM
    • Posts 108

    Hi,

     I used one gridview for main gridview , and used another gridview inside main gridview,

    In inside gridview I need add record function, so I put a "add" button on the footer. when I add the new record for the inside gridview,

    I also need id informaition which in the same line of main gridview. my problem is when click add button, fire the button event,

    but I can not find the row information for the main gridview which the inside gridview belong to?

     

    Can someone help me?

     

    Thanks in advance!

  • Re: how to nested the gridview

    12-17-2008, 7:55 PM
    Answer
    • Member
      204 point Member
    • cherishnews
    • Member since 10-24-2008, 7:51 AM
    • Posts 162

    Hi,

    I have done nested gridview before. But my case is a bit different from yours.

    Does the [Add] button exist in different rows (for inner gridview or outer gridview), or there is only 1 [Add] button (since you mentioned footer)?

    If you have [Add] button for each row, you can get the row information through the [Add] button. For my case I was dealing with checkbox, and this is what I did. Checkbox2 is checkbox in the inner gridview.

     Protected Sub CheckBox2_CheckedChanged(ByVal sender As Object, ByVal e As System.EventArgs)
            Dim chk As CheckBox = CType(sender, CheckBox)
            If chk.Checked = False Then
                Dim innergv As GridView = CType(chk.Parent.Parent.Parent.Parent, GridView)
                Dim myrow As GridViewRow = CType(innergv.Parent.Parent, GridViewRow)
                Dim outerChk As CheckBox = CType(myrow.FindControl("CheckBox1"), CheckBox)
                outerChk.Checked = False
                Dim outergv As GridView = CType(myrow.Parent.Parent, GridView)
            End If
        End Sub

     

    You can find row information of the outer gridview, through the "Parent" property as above.

    Hope this helps.

  • Re: how to nested the gridview

    12-18-2008, 11:53 AM
    • Member
      8 point Member
    • bjcanada
    • Member since 06-17-2008, 5:12 PM
    • Posts 108

    Thanks a lot!

    It is useful!

Page 1 of 1 (6 items)