Reputation: 52942
I have a dropdown control, with some values I added in using the designer.
For example, "ANY", "Male", "Female".
The value for Male is set to M
The value for Female is set to F
The value for ANY is blank.
However, although it seems to be blank, I spent hours trying to debug a parse error...
And to my horror I discovered it wasn't blank at all! The value was set to "ANY".
I want the value to be blank, because my SQL query checks if the string is blank (or null).
My program breaks when it tries to put "ANY" into a varchar(1) for obvious reasons.
Am I doing something wrong? How can I make the default value blank?
Upvotes: 1
Views: 110
Reputation: 21117
You can have a blank value, you can reference it like this:
DropDownList1.SelectedValue;
OR
DropDownList1.Text;
Upvotes: 1
Reputation: 12535
You need to set Value=""
<asp:DropDownList id="DropDownList1" runat="server">
<asp:ListItem value="" Text="ANY">
</asp:ListItem>
</asp:DropDownList>
If you still have your bug just set the value to 0 or one letter
Upvotes: 1