Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
How to set DropDownList Text value from cs file?
Message
 
General information
Forum:
ASP.NET
Category:
Other
Environment versions
Environment:
C# 3.0
OS:
Windows XP
Network:
Windows 2003 Server
Database:
MS SQL Server
Miscellaneous
Thread ID:
01336591
Message ID:
01336695
Views:
11
>Hi everybody,
>
>I need to be able to set text portion of the DropDownList from my code. I originally was just setting ddl SelectedValue and it worked well. However, I switched my approach to store the information in the text and in the value store something else. Now I could not figure out how to set text property in my case.
>
>I have this code
>
>if (value != "") // We don't have empty values in Schools
>                {//this.ddlSchool.SelectedValue = value;
>                    this.ddlSchool.Items[0].Text = value;
>                    this.hdnSchool.Value = value;
>                }
>
>
>
>and I just found it was not working (I have an exception). Any ideas how to set the text property?
>
>Thanks in advance.

I tried with FindByText in Pre-render, but there were some other strange issues. So at the end I used concatenated value School + | + Phone as value and was able to set SelectedValue for the dropdown.
If it's not broken, fix it until it is.


My Blog
Previous
Reply
Map
View

Click here to load this message in the networking platform