How can I select items in a datagrid to populate a second datagrid.

Discussion in 'ASP .Net Datagrid Control' started by Eric, Aug 2, 2004.

  1. Eric

    Eric Guest

    I currently have a datagrid that looks like the following.

    Sales Table
    Date Dogs Cats Fish
    5/1/2004 4 4 2
    5/2/2004 3 3 1
    5/4/2004 2 4 1
    5/5/2004 1 2 23

    I want to be able to click on each number and have a seperate datagrid
    pull up the individual sales records. For example, on 5/1/2004, I want
    to be able to click on the 4 cats hand have the second datagrid on the
    page pull the database details for those four records as shown below.

    5/1/2004 - Cats
    Sale QTY Customer
    Cat 1 4456
    Cat 2 2345
    Cat 1 1994

    I know how to build an handler to select rows in a datagrid but I want
    to select individual items within the rows since my sales for dogs,
    cats and fish are all in the same row.

    Currently, as a workaround I'm using a template colum to fill the
    cells as hyperlinks that just refresh the page while passing in the
    variables via querystring but it's quite cumbersome to maintain page
    state with this solution.

    Any ideas on a clean way to do this?

    Thanks

    Eric
    Eric, Aug 2, 2004
    #1
    1. Advertising

  2. Eric

    Thomas Dodds Guest

    This might help ...
    http://www.planet-source-code.com/vb/scripts/ShowCode.asp?txtCodeId=8760&lngWId=4

    or this http://www.c-sharpcorner.com/asp/Articles/MasterDetailDCHK.asp

    "Eric" <> wrote in message
    news:...
    > I currently have a datagrid that looks like the following.
    >
    > Sales Table
    > Date Dogs Cats Fish
    > 5/1/2004 4 4 2
    > 5/2/2004 3 3 1
    > 5/4/2004 2 4 1
    > 5/5/2004 1 2 23
    >
    > I want to be able to click on each number and have a seperate datagrid
    > pull up the individual sales records. For example, on 5/1/2004, I want
    > to be able to click on the 4 cats hand have the second datagrid on the
    > page pull the database details for those four records as shown below.
    >
    > 5/1/2004 - Cats
    > Sale QTY Customer
    > Cat 1 4456
    > Cat 2 2345
    > Cat 1 1994
    >
    > I know how to build an handler to select rows in a datagrid but I want
    > to select individual items within the rows since my sales for dogs,
    > cats and fish are all in the same row.
    >
    > Currently, as a workaround I'm using a template colum to fill the
    > cells as hyperlinks that just refresh the page while passing in the
    > variables via querystring but it's quite cumbersome to maintain page
    > state with this solution.
    >
    > Any ideas on a clean way to do this?
    >
    > Thanks
    >
    > Eric
    Thomas Dodds, Aug 3, 2004
    #2
    1. Advertising

  3. Eric

    Eric Guest

    Thomas,
    Thanks for the links but both these exampls allow data expansion via
    selecting a row. I want to be able to select different items within a
    row, each of which would yield a different datagrid. I need some sort
    of handler to detect which cell in the datagrid was selected.

    Thanks

    Eric

    "Thomas Dodds" <> wrote in message news:<>...
    > This might help ...
    > http://www.planet-source-code.com/vb/scripts/ShowCode.asp?txtCodeId=8760&lngWId=4
    >
    > or this http://www.c-sharpcorner.com/asp/Articles/MasterDetailDCHK.asp
    >
    > "Eric" <> wrote in message
    > news:...
    > > I currently have a datagrid that looks like the following.
    > >
    > > Sales Table
    > > Date Dogs Cats Fish
    > > 5/1/2004 4 4 2
    > > 5/2/2004 3 3 1
    > > 5/4/2004 2 4 1
    > > 5/5/2004 1 2 23
    > >
    > > I want to be able to click on each number and have a seperate datagrid
    > > pull up the individual sales records. For example, on 5/1/2004, I want
    > > to be able to click on the 4 cats hand have the second datagrid on the
    > > page pull the database details for those four records as shown below.
    > >
    > > 5/1/2004 - Cats
    > > Sale QTY Customer
    > > Cat 1 4456
    > > Cat 2 2345
    > > Cat 1 1994
    > >
    > > I know how to build an handler to select rows in a datagrid but I want
    > > to select individual items within the rows since my sales for dogs,
    > > cats and fish are all in the same row.
    > >
    > > Currently, as a workaround I'm using a template colum to fill the
    > > cells as hyperlinks that just refresh the page while passing in the
    > > variables via querystring but it's quite cumbersome to maintain page
    > > state with this solution.
    > >
    > > Any ideas on a clean way to do this?
    > >
    > > Thanks
    > >
    > > Eric
    Eric, Aug 3, 2004
    #3
  4. Eric

    Thomas Dodds Guest

    i very ugly way to do that would be to use buttoncolumns (linkbuttons) and
    trap individual datgrid itemcommands ...

    "Eric" <> wrote in message
    news:...
    > Thomas,
    > Thanks for the links but both these exampls allow data expansion via
    > selecting a row. I want to be able to select different items within a
    > row, each of which would yield a different datagrid. I need some sort
    > of handler to detect which cell in the datagrid was selected.
    >
    > Thanks
    >
    > Eric
    >
    > "Thomas Dodds" <> wrote in message

    news:<>...
    > > This might help ...
    > >

    http://www.planet-source-code.com/vb/scripts/ShowCode.asp?txtCodeId=8760&lngWId=4
    > >
    > > or this http://www.c-sharpcorner.com/asp/Articles/MasterDetailDCHK.asp
    > >
    > > "Eric" <> wrote in message
    > > news:...
    > > > I currently have a datagrid that looks like the following.
    > > >
    > > > Sales Table
    > > > Date Dogs Cats Fish
    > > > 5/1/2004 4 4 2
    > > > 5/2/2004 3 3 1
    > > > 5/4/2004 2 4 1
    > > > 5/5/2004 1 2 23
    > > >
    > > > I want to be able to click on each number and have a seperate datagrid
    > > > pull up the individual sales records. For example, on 5/1/2004, I want
    > > > to be able to click on the 4 cats hand have the second datagrid on the
    > > > page pull the database details for those four records as shown below.
    > > >
    > > > 5/1/2004 - Cats
    > > > Sale QTY Customer
    > > > Cat 1 4456
    > > > Cat 2 2345
    > > > Cat 1 1994
    > > >
    > > > I know how to build an handler to select rows in a datagrid but I want
    > > > to select individual items within the rows since my sales for dogs,
    > > > cats and fish are all in the same row.
    > > >
    > > > Currently, as a workaround I'm using a template colum to fill the
    > > > cells as hyperlinks that just refresh the page while passing in the
    > > > variables via querystring but it's quite cumbersome to maintain page
    > > > state with this solution.
    > > >
    > > > Any ideas on a clean way to do this?
    > > >
    > > > Thanks
    > > >
    > > > Eric
    Thomas Dodds, Aug 3, 2004
    #4
  5. Eric

    Thomas Dodds Guest

    something in here might help too -
    http://www.developersdex.com/asp/message.asp?p=1116&r=4403025

    "Eric" <> wrote in message
    news:...
    > Thomas,
    > Thanks for the links but both these exampls allow data expansion via
    > selecting a row. I want to be able to select different items within a
    > row, each of which would yield a different datagrid. I need some sort
    > of handler to detect which cell in the datagrid was selected.
    >
    > Thanks
    >
    > Eric
    >
    > "Thomas Dodds" <> wrote in message

    news:<>...
    > > This might help ...
    > >

    http://www.planet-source-code.com/vb/scripts/ShowCode.asp?txtCodeId=8760&lngWId=4
    > >
    > > or this http://www.c-sharpcorner.com/asp/Articles/MasterDetailDCHK.asp
    > >
    > > "Eric" <> wrote in message
    > > news:...
    > > > I currently have a datagrid that looks like the following.
    > > >
    > > > Sales Table
    > > > Date Dogs Cats Fish
    > > > 5/1/2004 4 4 2
    > > > 5/2/2004 3 3 1
    > > > 5/4/2004 2 4 1
    > > > 5/5/2004 1 2 23
    > > >
    > > > I want to be able to click on each number and have a seperate datagrid
    > > > pull up the individual sales records. For example, on 5/1/2004, I want
    > > > to be able to click on the 4 cats hand have the second datagrid on the
    > > > page pull the database details for those four records as shown below.
    > > >
    > > > 5/1/2004 - Cats
    > > > Sale QTY Customer
    > > > Cat 1 4456
    > > > Cat 2 2345
    > > > Cat 1 1994
    > > >
    > > > I know how to build an handler to select rows in a datagrid but I want
    > > > to select individual items within the rows since my sales for dogs,
    > > > cats and fish are all in the same row.
    > > >
    > > > Currently, as a workaround I'm using a template colum to fill the
    > > > cells as hyperlinks that just refresh the page while passing in the
    > > > variables via querystring but it's quite cumbersome to maintain page
    > > > state with this solution.
    > > >
    > > > Any ideas on a clean way to do this?
    > > >
    > > > Thanks
    > > >
    > > > Eric
    Thomas Dodds, Aug 3, 2004
    #5
  6. Eric

    Guest

    Two otions are available.
    First use the Reapter control to create and populate
    an html table?
    Each cell looks like this when sent to the browser
    <td><a href="thispage.aspx?cellrow=ID>TheData</a></td>

    Second use the DataGrid. In your .aspx
    Use the DataGrid ItemDataBound event.
    ItemDataBound(
    object sender, System.Web.UI.WebControls.DataGridItemEventArgs e)
    {
    DataGridItem dgi = e.Item;

    // hyperlink the data in cell 0.
    strData = dgi.Cells[0].Text;
    hlink = new System.Web.UI.WebControls.HyperLink();
    hlink.NavigateUrl = strTheDatasURL;
    hlink.Text = strData;
    dgi.Cells[0].Controls.AddAt(0, hlink);
    }

    In either case use thispage.aspx?cellrow=ID as the URL
    Let cellrow=ID thell your aspx code which detail is
    to be diplayed.

    Hope this helps...


    Thomas Dodds wrote:

    > something in here might help too -
    > http://www.developersdex.com/asp/message.asp?p=1116&r=4403025
    >
    > "Eric" <> wrote in message
    > news:...
    >
    >>Thomas,
    >>Thanks for the links but both these exampls allow data expansion via
    >>selecting a row. I want to be able to select different items within a
    >>row, each of which would yield a different datagrid. I need some sort
    >>of handler to detect which cell in the datagrid was selected.
    >>
    >>Thanks
    >>
    >>Eric
    >>
    >>"Thomas Dodds" <> wrote in message
    >>

    > news:<>...
    >
    >>>This might help ...
    >>>
    >>>

    > http://www.planet-source-code.com/vb/scripts/ShowCode.asp?txtCodeId=8760&lngWId=4
    >
    >>>or this http://www.c-sharpcorner.com/asp/Articles/MasterDetailDCHK.asp
    >>>
    >>>"Eric" <> wrote in message
    >>>news:...
    >>>
    >>>>I currently have a datagrid that looks like the following.
    >>>>
    >>>>Sales Table
    >>>>Date Dogs Cats Fish
    >>>>5/1/2004 4 4 2
    >>>>5/2/2004 3 3 1
    >>>>5/4/2004 2 4 1
    >>>>5/5/2004 1 2 23
    >>>>
    >>>>I want to be able to click on each number and have a seperate datagrid
    >>>>pull up the individual sales records. For example, on 5/1/2004, I want
    >>>>to be able to click on the 4 cats hand have the second datagrid on the
    >>>>page pull the database details for those four records as shown below.
    >>>>
    >>>>5/1/2004 - Cats
    >>>>Sale QTY Customer
    >>>>Cat 1 4456
    >>>>Cat 2 2345
    >>>>Cat 1 1994
    >>>>
    >>>>I know how to build an handler to select rows in a datagrid but I want
    >>>>to select individual items within the rows since my sales for dogs,
    >>>>cats and fish are all in the same row.
    >>>>
    >>>>Currently, as a workaround I'm using a template colum to fill the
    >>>>cells as hyperlinks that just refresh the page while passing in the
    >>>>variables via querystring but it's quite cumbersome to maintain page
    >>>>state with this solution.
    >>>>
    >>>>Any ideas on a clean way to do this?
    >>>>
    >>>>Thanks
    >>>>
    >>>>Eric
    >>>>

    >
    >
    , Aug 4, 2004
    #6
    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. Patrik
    Replies:
    0
    Views:
    455
    Patrik
    Mar 27, 2006
  2. C Wilson
    Replies:
    1
    Views:
    357
    David Carlisle
    Dec 16, 2006
  3. Enjoy Life
    Replies:
    2
    Views:
    261
    Roland Hall
    Feb 23, 2005
  4. Gumtree
    Replies:
    3
    Views:
    242
    Matt Kruse
    Nov 10, 2004
  5. yelipolok
    Replies:
    4
    Views:
    244
    John W. Krahn
    Jan 27, 2010
Loading...

Share This Page