Should be simple...

R

Rob

I am new to asp.net.... but this should be simple, yet it does not appear to
work. I must be doing something wrong.

I have a web form with a dropdown list. I have successfully populated it
with data from sql server using a datareader.

How do you reference the item that you selected in the dropdown list (after
you select it) ?

My dropdown list is called ddJob.

I tried to simply place the value I selected into a text box....

Within the ddJob_SelectedIndexChanged I tried...

Textbox1.Text=ddJob.SelectedValue

But nothing happens when I select a value form the dropdown list..... Why ?

Thanks !
 
M

^MisterJingo^

Rob said:
I am new to asp.net.... but this should be simple, yet it does not appear to
work. I must be doing something wrong.

I have a web form with a dropdown list. I have successfully populated it
with data from sql server using a datareader.

How do you reference the item that you selected in the dropdown list (after
you select it) ?

My dropdown list is called ddJob.

I tried to simply place the value I selected into a text box....

Within the ddJob_SelectedIndexChanged I tried...

Textbox1.Text=ddJob.SelectedValue

But nothing happens when I select a value form the dropdown list..... Why ?

Thanks !

Is the dropdownlist being rebound on each page load? If so, the data is
being lost. You need to put the binding code in something like:

if(!IsPostBack)
{
// code here
}
 
S

Steven Nagy

Hi Rob,

You are nearly doing everything right!
It seems you are missing one little thing.
Its called "AutoPostBack" and it needs to be set to true.
Its on the drop down list properties.

What this means is that when you change the selected index, it will
post the data back to the server immediately, rather than when a button
is clicked.

Try it out!

Steven
 

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,769
Messages
2,569,582
Members
45,062
Latest member
OrderKetozenseACV

Latest Threads

Top