Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > ASP .Net > Getting DropDownList selected value

Reply
Thread Tools

Getting DropDownList selected value

 
 
=?Utf-8?B?Sm9u?=
Guest
Posts: n/a
 
      04-24-2006
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
 
Reply With Quote
 
 
 
 
Eliyahu Goldin
Guest
Posts: n/a
 
      04-24-2006
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" <(E-Mail Removed)> wrote in message
news:(E-Mail Removed)...
> 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



 
Reply With Quote
 
 
 
 
bruce barker \(sqlwork.com\)
Guest
Posts: n/a
 
      04-24-2006
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" <(E-Mail Removed)> wrote in message
news:(E-Mail Removed)...
> 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



 
Reply With Quote
 
=?Utf-8?B?Sm9u?=
Guest
Posts: n/a
 
      04-25-2006
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" <(E-Mail Removed)> wrote in message
> news:(E-Mail Removed)...
> > 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

>
>
>

 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Selected ListItem in DropDownList does not appear selected Nathan Sokalski ASP .Net Web Controls 0 10-05-2008 10:29 PM
Selected ListItem in DropDownList does not appear selected Nathan Sokalski ASP .Net 0 10-05-2008 10:29 PM
DropDownList 2 always returns Selected = 0 for all items - even selected item Iain ASP .Net 3 12-11-2006 11:07 AM
Getting and Setting Selected Value for a Dropdownlist in an Editable DataLister jack ASP .Net Web Controls 0 05-09-2004 01:39 AM
Getting and Setting Selected Value for a Dropdownlist in an Editable DataLister jack ASP .Net 0 05-09-2004 01:39 AM



Advertisments