GridView inside gridView

Posted on 2007-08-07
Last Modified: 2008-01-09
Hi all,
I have a master/child type of report: 2 table tbl_part with partID as primary key and tbl_modification with modificationID as primary key and partID as foreign key.
I was able to create my nested gidviews and it for each part in the tbl_part it shows the corresponding modifications.
I added a button in gridView2, and what I want is to run some code when the button is clicked. And for that I need to get the key for gridView2. But i couldn't figure out how to do it . Please help with suggestions, codes or url's.
Thank you.
Question by:ki_ki
    LVL 10

    Accepted Solution

    LVL 12

    Expert Comment

    Put your second GridView in ItemTemplate of FirstGridView

    Then set gridview2 datasource in Gridview1's RowDataBound event

    LVL 4

    Author Comment

    Thank you to both of you.
    The problem I have is not 'creating' the nested girdViews: my 2 gridViews work fine, meaning they display the data the way I want, ie, One-to-many type relationship.
    What I need, is access to gridView2's key(modificationID) from a button on girdView2. Let me know if i am not clear.
    LVL 4

    Author Comment

    SystemExpert, the 1st link you provided gave me a hint:

    The solution to what I was looking for is below:

    Protected Sub GridView2_RowCommand(ByVal sender As Object, ByVal e As


            Dim myGrid1 As GridView
            mygrid1 = CType(sender, GridView)
    myGrid1.Rows(e.CommandArgument).Cells(0).Text ............this the key I am looking for
    End sub

    Tank you

    Write Comment

    Please enter a first name

    Please enter a last name

    We will never share this with anyone.

    Featured Post

    What Is Threat Intelligence?

    Threat intelligence is often discussed, but rarely understood. Starting with a precise definition, along with clear business goals, is essential.

    Just a quick little trick I learned recently.  Now that I'm using jQuery with abandon in my applications, I have grown tired of the following syntax:      (CODE) I suppose it just offends my sense of decency to put inline VBScript on a…
    Creating an analog clock UserControl seems fairly straight forward.  It is, after all, essentially just a circle with several lines in it!  Two common approaches for rendering an analog clock typically involve either manually calculating points with…
    Sending a Secure fax is easy with eFax Corporate ( First, Just open a new email message.  In the To field, type your recipient's fax number You can even send a secure international fax — just include t…
    Access reports are powerful and flexible. Learn how to create a query and then a grouped report using the wizard. Modify the report design after the wizard is done to make it look better. There will be another video to explain how to put the final p…

    737 members asked questions and received personalized solutions in the past 7 days.

    Join the community of 500,000 technology professionals and ask your questions.

    Join & Ask a Question

    Need Help in Real-Time?

    Connect with top rated Experts

    19 Experts available now in Live!

    Get 1:1 Help Now