-1

Hello everyone,
Please am working on a project basically for storing personal data for some employees. I have a dropdownlistbox which gets its content from a table in SQL-Server. I also have a textbox which i want its text to be the same with the selectedted item of the dropdownlist but it seems not to be working

Here's my simple code which was inplemented in the dropdownlistbox_Selectedindexchanged Procedure:

TextBox1.Text = DropdownListBox1.SelectedItem.ToString
6
Contributors
11
Replies
12
Views
6 Years
Discussion Span
Last Post by Pgmer
0
TextBox1.Text = DropdownListBox1.Selectedtext.ToString

or

TextBox1.Text = DropdownListBox1.Text.ToString

try these two..

0

Hi pgmer, i've tried that before and it shows nothing on the textbox. Am actually not a newbie so am also surprised that did not work. Its actually the VS2010 Professional so am wondering if there's any change in the process. Please help

0
TextBox1.Text = DropdownListBox1.Text.ToStringTextBox1.Text = DropdownListBox1.Text.ToString()[

This should work man... :( i dont know whats the problem. can u paste ur code here if u can?

0

chibex64,

My first thought is to debug and make sure that the event is actually getting fired, I'm guessing you know how to do that and have done so already.

That said, I'm using the same set up as you are VS 2010 Professional. I normally use

TextBox.Text = DropDown1.SelectedValue;

to accomplish a similar thing, have you tried this? I know it is very similar to what was stated above, but that's what works for me in VS2010.

Also, it's not a bad idea while debugging to check the selected value of the drop down. Again, I'm fairly certain you have already tried this, but a thought if you haven't.

0

i think you are binding dropdown data in pageload event.
try below code..
if(!page.ispostback)
{
dropdownlistbinding();
}

now you will get values in textbox using dropdown values

0

Thanks Crishlay, but ma not doing that in a page_load event. Its in the selectedindexChanged event of the dropdown control and it does not work. i really dont know whats wrong.

0

Yousuf, how many time do i have to show my code? well, here it is:

Textbox1.text = DropDownList.text.tostring
0

all these have been tried, none seems to be working. I dont know if there's a problem somewhere

0

Textbox1.text = DropDownList.text.tostring() Try this... Sumtines if u miss paranthysis for .tostring method it wont work

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.