Filling One DataGrid Based on Selection from Another DataGrid - Both in Separate User Controls

Discussion in 'ASP .Net' started by thegame, Feb 22, 2005.

  1. thegame

    thegame Guest

    Filling One DataGrid Based on Selection from Another DataGrid - Both in
    Separate User Controls


    Hello, I have an interesting dilemma.

    I have an ASPX page with two user controls (two ASCXs). Both ASCXs have
    DataGrids on them. The first user control's DataGrid is populated from our
    database on page load. The DataGrid also has a Select LinkButton.

    What I need is for the selected row in the first DataGrid to be used as
    input to another query that dynamically fills the second DataGrid. This
    second DataGrid is in the second user control. I'm having trouble doing
    this. Any suggestions????

    In my first user control, I have the item command event for the first
    DataGrid as such:

    private void DataGrid1_ItemCommand(object source, DataGridCommandEventArgs
    e)
    {
    if (e.CommandName == "SelectMasterReport")
    {
    // get the selected value needed using e.Item.Cells[3].Text
    // code here to populate the second DataGrid?????
    }
    }

    Thanks in advance for any help!
     
    thegame, Feb 22, 2005
    #1
    1. Advertising

  2. RE: Filling One DataGrid Based on Selection from Another DataGrid - Bo

    Ok, here is my explanation....

    We have 3 parts: 1) .aspx 2). Main .ascx 3). sencondary .ascx

    First thing to do (which you have done already) is load the main .ascx
    (datagrid). I imagine that you are exposing the DataSource property of the
    datagrid on the main .ascx control.

    Next, you will have to create a bubble event within the main .ascx control
    so that ItemCommand event of the datagrid will bubble up to the .aspx page.
    Create properties of the data you need in order to fill the 2nd Datagrid

    Now you have the event that fires in the .aspx page, capture the properties
    that you set in the .ascx control and set the DataSource property of the
    second .ascx control.

    Seems like the only step you are missing is bubbling up the ItemCommand
    event from the main .ascx control to the .aspx page......and creating and
    grabbing the data from the main .ascx control and use it to set the
    DataSource property of the second .ascx control.

    Hope this helps !


    "thegame" wrote:

    > Filling One DataGrid Based on Selection from Another DataGrid - Both in
    > Separate User Controls
    >
    >
    > Hello, I have an interesting dilemma.
    >
    > I have an ASPX page with two user controls (two ASCXs). Both ASCXs have
    > DataGrids on them. The first user control's DataGrid is populated from our
    > database on page load. The DataGrid also has a Select LinkButton.
    >
    > What I need is for the selected row in the first DataGrid to be used as
    > input to another query that dynamically fills the second DataGrid. This
    > second DataGrid is in the second user control. I'm having trouble doing
    > this. Any suggestions????
    >
    > In my first user control, I have the item command event for the first
    > DataGrid as such:
    >
    > private void DataGrid1_ItemCommand(object source, DataGridCommandEventArgs
    > e)
    > {
    > if (e.CommandName == "SelectMasterReport")
    > {
    > // get the selected value needed using e.Item.Cells[3].Text
    > // code here to populate the second DataGrid?????
    > }
    > }
    >
    > Thanks in advance for any help!
    >
    >
    >
     
    =?Utf-8?B?ZGlyazQx?=, Feb 28, 2005
    #2
    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. qwerty
    Replies:
    3
    Views:
    9,289
    Scott Allen
    Sep 30, 2004
  2. EvgueniB
    Replies:
    1
    Views:
    635
    Anthony Borla
    Dec 15, 2003
  3. Replies:
    1
    Views:
    212
  4. Mohsen Pahlevanzadeh
    Replies:
    0
    Views:
    121
    Mohsen Pahlevanzadeh
    Sep 9, 2013
  5. MRAB
    Replies:
    0
    Views:
    119
Loading...

Share This Page