>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