nested datagrids

Discussion in 'ASP .Net Datagrid Control' started by source, Nov 30, 2003.

  1. source

    source Guest

    I need to implement a grid within a grid. How can I do this.
    The reason I need to do this is because I need to show related data within a
    grid from two different tables.

    source
    source, Nov 30, 2003
    #1
    1. Advertising

  2. source

    Jos Guest

    source wrote:
    > I need to implement a grid within a grid. How can I do this.
    > The reason I need to do this is because I need to show related data
    > within a grid from two different tables.
    >
    > source


    Put the second grid in the ItemTemplate of the first grid.
    Use the OnItemBound event of the first grid to bind the second grid.

    --

    Jos
    Jos, Nov 30, 2003
    #2
    1. Advertising

  3. source

    source Guest

    As a matter of fact I tried using a datagrid within the ItemTemplate, but
    for some reason it did not work.
    Can you tell me little more about this.


    "Jos" <> wrote in message
    news:...
    > source wrote:
    > > I need to implement a grid within a grid. How can I do this.
    > > The reason I need to do this is because I need to show related data
    > > within a grid from two different tables.
    > >
    > > source

    >
    > Put the second grid in the ItemTemplate of the first grid.
    > Use the OnItemBound event of the first grid to bind the second grid.
    >
    > --
    >
    > Jos
    >
    >
    source, Nov 30, 2003
    #3
  4. source

    Jos Guest

    source wrote:
    > As a matter of fact I tried using a datagrid within the ItemTemplate,
    > but for some reason it did not work.
    > Can you tell me little more about this.


    In the OnItemDataBound() event for the main datagrid, find the nested
    datagrid like this:

    Dim ndg As DataGrid = CType(e.Item.FindControl("DataGrid2",DataGrid))

    Then perform databinding on it:

    ndg.DataSource=whatever (probably depending on some data in e.Item)
    ndg.DataBind()

    Here's some examples with repeaters instead of datagrids:
    http://www.c-sharpcorner.com/Code/2002/Aug/MasterDetailedDisplay.asp
    http://authors.aspalliance.com/aylar/ViewArticle.aspx?ArticleID=4&PageID=1

    Here's an example with a datagrid constructed on the fly:
    http://www.dotnetjunkies.com/Tutorial/47792CB0-0990-4BD8-BF84-B6063C4C9BBC.dcik


    --

    Jos
    Jos, Nov 30, 2003
    #4
  5. source

    IK Guest

    IK, Dec 1, 2003
    #5
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Juliano Bortolozzi

    Re: Nested Datagrids

    Juliano Bortolozzi, Jul 14, 2003, in forum: ASP .Net
    Replies:
    0
    Views:
    424
    Juliano Bortolozzi
    Jul 14, 2003
  2. Dave

    Nested DataGrids

    Dave, Jul 15, 2003, in forum: ASP .Net
    Replies:
    1
    Views:
    622
    S. Justin Gengo
    Jul 15, 2003
  3. Dave

    Nested DataGrids

    Dave, Jul 21, 2003, in forum: ASP .Net
    Replies:
    1
    Views:
    392
    Ray Dixon [MVP]
    Jul 21, 2003
  4. Dave T

    Edit Nested Datagrids

    Dave T, Nov 3, 2003, in forum: ASP .Net
    Replies:
    0
    Views:
    398
    Dave T
    Nov 3, 2003
  5. ProgramAnalyst

    nested datagrids

    ProgramAnalyst, Nov 4, 2004, in forum: ASP .Net
    Replies:
    3
    Views:
    428
    ProgramAnalyst
    Nov 5, 2004
Loading...

Share This Page