Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
How to set DropDownList Text value from cs file?
Message
 
 
Information générale
Forum:
ASP.NET
Catégorie:
Autre
Versions des environnements
Environment:
C# 3.0
OS:
Windows XP
Network:
Windows 2003 Server
Database:
MS SQL Server
Divers
Thread ID:
01336591
Message ID:
01336695
Vues:
10
>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
Précédent
Répondre
Fil
Voir

Click here to load this message in the networking platform