DropDownList values are case sensitive?

  • Thread starter Thread starter Boban Dragojlovic
  • Start date Start date
B

Boban Dragojlovic

Say I have a dropdownlist control of the US State Codes
<asp:dropdownlist id=ddlStateCode ...>
<asp:listitem value="AL">Alabama</asp:listitem>
<asp:listitem value="CA">California</asp:listitem>
etc...


In my codebehind, I have something like this:

ddlStateCode.SelectedValue = UserRecord.StateCode


the problem is that if the UserRecord.StateCode is not in caps, I get an
error. In other words, the 'SelectedValue' property is case sensitive.

I have tried using 'OPTION COMPARE TEXT' but it didn't help.

Is there a way of making it NOT be case sensitive?
 
Hi Boban,

Please try changing your code to something like this:
If ddlStateCode.SelectedValue.ToUpper() = UserRecord.StateCode.ToUpper()
Then

Thank you, Mike
Microsoft, ASP.NET Support Professional

Microsoft highly recommends to all of our customers that they visit the
http://www.microsoft.com/protect site and perform the three straightforward
steps listed to improve your computer’s security.

This posting is provided "AS IS", with no warranties, and confers no rights.


--------------------
 
Back
Top