Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
How to get the Selected text value (not the SelectedValue)
Message
 
 
To
All
General information
Forum:
ASP.NET
Category:
Coding, syntax and commands
Title:
How to get the Selected text value (not the SelectedValue)
Environment versions
Environment:
C# 3.0
OS:
Windows XP
Network:
Windows 2003 Server
Database:
MS SQL Server
Miscellaneous
Thread ID:
01335710
Message ID:
01335710
Views:
52
Hi everybody,

I have a DropDown list. I have its value set to something else and the text set to the actual value. Now I'm having a problem to get this selected text back.

I tried
return this.ddlSchool.Items[this.ddlSchool.SelectedIndex].Text ;
// but it returns the original value, not the actual selected text
What could be the problem?

I also have onchange attribute set to
string script = "ChangePhone('" + this.lblSchoolPhone.ClientID + "', this.options[this.selectedIndex].value)"; 
                           
        this.ddlSchool.Attributes.Add("onchange", script);
Could it be that having onchange JavaScript event somehow interferes with the value? It should not be.

Any ideas welcomed because it's late and I need to get it done ASAP.

Thanks in advance.
If it's not broken, fix it until it is.


My Blog
Next
Reply
Map
View

Click here to load this message in the networking platform