Getting DropDownList selected value

G

Guest

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
 
E

Eliyahu Goldin

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
 
B

bruce barker \(sqlwork.com\)

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)
 
G

Guest

Thats just the ticket Bruce, thanks very much!

bruce barker (sqlwork.com) said:
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)
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,756
Messages
2,569,535
Members
45,008
Latest member
obedient dusk

Latest Threads

Top