Re: need selected value from dropdown list box

Discussion in 'ASP .Net' started by Scott Allen, Aug 25, 2004.

  1. Scott Allen

    Scott Allen Guest

    Hi Paul:

    I have some code to demonstrate how to do this about half way through
    the following article:
    http://odetocode.com/Articles/116.aspx

    HTH,

    --
    Scott
    http://www.OdeToCode.com

    On Wed, 25 Aug 2004 09:19:14 -0700, "Paul"
    <> wrote:

    >Hi just wondering how to get the selected value from a dropdown list box in a
    >template column of a datagrid? I set up the DataGrid1_ItemCommand method and
    >put a breakpoint in it but after making a selection from the dropdown list
    >box the breakpoint is not hit.
    >Thanks.
    Scott Allen, Aug 25, 2004
    #1
    1. Advertising

  2. Scott Allen

    Scott Allen Guest

    Hi Paul:

    This is the SelectedIndexChanged event handler for the DropDownList?
    This should work, if AutoPostBack is set to true for the DropDownList.

    Also, I'm not sure if DataGrid1.SelectedIndex will be current with
    where the user changed the DropDownList. You might have to work up the
    DropDownList object's Parent property till you get to the
    DataGridItem, then use FindControl to get the TextBox.

    Hope makes some sense...

    --
    Scott
    http://www.OdeToCode.com



    On Wed, 25 Aug 2004 11:15:09 -0700, "Paul"
    <> wrote:

    >Hi Scott, thanks for the information. I think I found the code you were
    >talking about, see below. I have a Selected inex change method but can not
    >get the event to fire, part of the grid is databound (just displays data from
    >a dbase) and other columns are dropdown list boxes. I was hoping this event
    >would fire when the user made a selection in the dropdown list box, (template
    >column of the grid).
    >private void DataGrid1_SelectedIndexChanged(object sender, System.EventArgs e)
    >{
    > TextBox b;
    > b = DataGrid1.Items[DataGrid1.SelectedIndex].FindControl("TextBox1") as
    >TextBox;
    > if(b != null)
    > {
    > Response.Write("Sender = " + sender.GetType().ToString() + "<br>");
    > Response.Write("Found Textbox1 in SelectedIndexChanged event<br>");
    > Response.Write(FindUtil.DumpParent(b));
    > }
    >}
    >
    >
    >
    >"Scott Allen" wrote:
    >
    >> Hi Paul:
    >>
    >> I have some code to demonstrate how to do this about half way through
    >> the following article:
    >> http://odetocode.com/Articles/116.aspx
    >>
    >> HTH,
    >>
    >> --
    >> Scott
    >> http://www.OdeToCode.com
    >>
    >> On Wed, 25 Aug 2004 09:19:14 -0700, "Paul"
    >> <> wrote:
    >>
    >> >Hi just wondering how to get the selected value from a dropdown list box in a
    >> >template column of a datagrid? I set up the DataGrid1_ItemCommand method and
    >> >put a breakpoint in it but after making a selection from the dropdown list
    >> >box the breakpoint is not hit.
    >> >Thanks.

    >>
    >>
    Scott Allen, Aug 25, 2004
    #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. Andy Sutorius

    how to get selected value from dropdown list

    Andy Sutorius, Mar 15, 2005, in forum: ASP .Net
    Replies:
    6
    Views:
    82,161
    raouf2me
    Oct 29, 2012
  2. =?Utf-8?B?SklNLkgu?=

    Q: dropdown list, no selected value

    =?Utf-8?B?SklNLkgu?=, Apr 12, 2005, in forum: ASP .Net
    Replies:
    2
    Views:
    602
    Eliyahu Goldin
    Apr 12, 2005
  3. Guest
    Replies:
    6
    Views:
    10,115
    Rajesh
    Jan 8, 2006
  4. vishnu
    Replies:
    1
    Views:
    1,179
    Patrick.O.Ige
    Mar 25, 2006
  5. mldardy
    Replies:
    1
    Views:
    734
    mldardy
    Dec 10, 2008
Loading...

Share This Page