Getting DropDownList selected value

Discussion in 'ASP .Net' started by =?Utf-8?B?Sm9u?=, Apr 24, 2006.

  1. Hello all,

    Through JavaScript, I add a row to a DataGrid. This new row has a number of
    columns, one of which contains a SELECT control with a couple of items -
    again, all done through JavaScript.

    My question is, how on the page postback, in the page's codebehind, do I get
    a reference to this SELECT contol so that I get the selected value.

    Thanks all,

    Jon
    =?Utf-8?B?Sm9u?=, Apr 24, 2006
    #1
    1. Advertising

  2. Jon,

    Whatever you add in javascript is not available on server side unless you
    pass it on there specifically.

    Introduce a hidden input control and pass the selected value in it.

    Eliyahu


    "Jon" <> wrote in message
    news:...
    > Hello all,
    >
    > Through JavaScript, I add a row to a DataGrid. This new row has a number
    > of
    > columns, one of which contains a SELECT control with a couple of items -
    > again, all done through JavaScript.
    >
    > My question is, how on the page postback, in the page's codebehind, do I
    > get
    > a reference to this SELECT contol so that I get the selected value.
    >
    > Thanks all,
    >
    > Jon
    Eliyahu Goldin, Apr 24, 2006
    #2
    1. Advertising

  3. if your javascript set the name to the <select>, when posted back, your code
    behind can look it up by the same name in the Request.Form collection by its
    name. if you don't know the name use a pattern and loop thru the collection
    looking for the name pattern.

    note: if you name two (or more) controls the same, the server creates a
    comma seperated list as the value in the form collection for the controls.


    -- bruce (sqlwork.com)



    "Jon" <> wrote in message
    news:...
    > Hello all,
    >
    > Through JavaScript, I add a row to a DataGrid. This new row has a number
    > of
    > columns, one of which contains a SELECT control with a couple of items -
    > again, all done through JavaScript.
    >
    > My question is, how on the page postback, in the page's codebehind, do I
    > get
    > a reference to this SELECT contol so that I get the selected value.
    >
    > Thanks all,
    >
    > Jon
    bruce barker \(sqlwork.com\), Apr 24, 2006
    #3
  4. Thats just the ticket Bruce, thanks very much!

    "bruce barker (sqlwork.com)" wrote:

    > if your javascript set the name to the <select>, when posted back, your code
    > behind can look it up by the same name in the Request.Form collection by its
    > name. if you don't know the name use a pattern and loop thru the collection
    > looking for the name pattern.
    >
    > note: if you name two (or more) controls the same, the server creates a
    > comma seperated list as the value in the form collection for the controls.
    >
    >
    > -- bruce (sqlwork.com)
    >
    >
    >
    > "Jon" <> wrote in message
    > news:...
    > > Hello all,
    > >
    > > Through JavaScript, I add a row to a DataGrid. This new row has a number
    > > of
    > > columns, one of which contains a SELECT control with a couple of items -
    > > again, all done through JavaScript.
    > >
    > > My question is, how on the page postback, in the page's codebehind, do I
    > > get
    > > a reference to this SELECT contol so that I get the selected value.
    > >
    > > Thanks all,
    > >
    > > Jon

    >
    >
    >
    =?Utf-8?B?Sm9u?=, Apr 25, 2006
    #4
    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. jack
    Replies:
    0
    Views:
    335
  2. Iain
    Replies:
    3
    Views:
    928
  3. Nathan Sokalski
    Replies:
    0
    Views:
    607
    Nathan Sokalski
    Oct 5, 2008
  4. jack
    Replies:
    0
    Views:
    114
  5. Nathan Sokalski

    Selected ListItem in DropDownList does not appear selected

    Nathan Sokalski, Oct 5, 2008, in forum: ASP .Net Web Controls
    Replies:
    0
    Views:
    290
    Nathan Sokalski
    Oct 5, 2008
Loading...

Share This Page