Beginner gridview question

Discussion in 'ASP .Net' started by Paul, Jul 2, 2008.

  1. Paul

    Paul Guest

    Just wondering if anyone knows if this is possible with a gridview but I have
    a template column with two dropdown list boxes in it and when the user makes
    a selection in the first box I want to run an event that then takes the
    selected value of the first dropdown and feeds it into a stored procedure
    that returns a dataset that I want to display in the second dropdown list.
    If there is no data returned I want to hide the second dropdown list, any
    examples, thanks. I was doing this quite easily with the controls outside of
    the datagrid.
    Thanks.
    --
    Paul G
    Software engineer.
     
    Paul, Jul 2, 2008
    #1
    1. Advertising

  2. Paul

    jm Guest

    On Jul 2, 4:06 pm, Paul <> wrote:
    > Just wondering if anyone knows if this is possible with a gridview but I have
    > a template column with two dropdown list boxes in it and when the user makes
    > a selection in the first box I want to run an event that then takes the
    > selected value of the first dropdown and feeds it into a stored procedure
    > that returns a dataset that I want to display in the second dropdown list..  
    > If there is no data returned I want to hide the second dropdown list, any
    > examples, thanks.  I was doing this quite easily with the controls outside of
    > the datagrid.
    > Thanks.
    > --
    > Paul G
    > Software engineer.


    If you make them template columns, you can reference them in code
    easier, which may be what you did outside of the datagrid you
    mentioned.
     
    jm, Jul 2, 2008
    #2
    1. Advertising

  3. Paul

    Paul Guest

    Thanks for the response. I think something like below may work as I am able
    to access the selected values in the template column. There is also a label
    in the column as well. I will just need to rebind the secondary dropdown
    feeding the selected value into the datasource first.

    protected void drdn1_SelectedIndexChanged(object sender, EventArgs e)
    {
    foreach (GridViewRow myRow in this.gvwDiscrepancies.Rows)
    {
    Label lbl1 = myRow.Cells[2].Controls[1] as Label;
    DropDownList drdn1 = myRow.Cells[2].Controls[7] as DropDownList;
    if (drdn1 != null)
    {
    string stemp = drdn1.SelectedValue.ToString();
    }
    }
    }
    --
    Paul G
    Software engineer.


    "jm" wrote:

    > On Jul 2, 4:06 pm, Paul <> wrote:
    > > Just wondering if anyone knows if this is possible with a gridview but I have
    > > a template column with two dropdown list boxes in it and when the user makes
    > > a selection in the first box I want to run an event that then takes the
    > > selected value of the first dropdown and feeds it into a stored procedure
    > > that returns a dataset that I want to display in the second dropdown list..
    > > If there is no data returned I want to hide the second dropdown list, any
    > > examples, thanks. I was doing this quite easily with the controls outside of
    > > the datagrid.
    > > Thanks.
    > > --
    > > Paul G
    > > Software engineer.

    >
    > If you make them template columns, you can reference them in code
    > easier, which may be what you did outside of the datagrid you
    > mentioned.
    >
     
    Paul, Jul 2, 2008
    #3
    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. =?Utf-8?B?S3VydCBTY2hyb2VkZXI=?=

    No Class at ALL!!! beginner/beginner question

    =?Utf-8?B?S3VydCBTY2hyb2VkZXI=?=, Feb 2, 2005, in forum: ASP .Net
    Replies:
    7
    Views:
    657
    =?Utf-8?B?S3VydCBTY2hyb2VkZXI=?=
    Feb 3, 2005
  2. =?Utf-8?B?bWdvbnphbGVzMw==?=

    GridView Hierarchical View - Gridview in Gridview

    =?Utf-8?B?bWdvbnphbGVzMw==?=, May 9, 2006, in forum: ASP .Net
    Replies:
    1
    Views:
    18,043
    =?Utf-8?B?UGhpbGxpcCBXaWxsaWFtcw==?=
    May 9, 2006
  3. Rensjuh
    Replies:
    7
    Views:
    1,045
    Mabden
    Sep 2, 2004
  4. Cirene
    Replies:
    1
    Views:
    387
    gnewsgroup
    Nov 4, 2007
  5. william nelson

    Beginner's Beginner

    william nelson, Apr 11, 2011, in forum: Ruby
    Replies:
    7
    Views:
    262
    7stud --
    Apr 12, 2011
Loading...

Share This Page