Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Empty Row In Combo
Message
From
14/02/2009 12:54:20
 
General information
Forum:
ASP.NET
Category:
Coding, syntax and commands
Miscellaneous
Thread ID:
01381353
Message ID:
01381787
Views:
15
>What I did which seemed to work was insert a row into the DS with "None" using the Table.InsertAt() method so that it is the first row in the DS.

Well, ok, whatever your requirements are for your app. But personally, I, as a user, would rather see an empty ComboBox rather than the word "None".

~~Bonnie



>
>>Kevin,
>>
>>You're close ... in addition to setting the .SelectedIndex to -1, you also need to set the .SelectedValue. If you've bound your ValueMember to a string, then that's easy, just set the .SelectedValue to "". It's more complicated if it's bound to a numeric column, such as an int ... in those cases we've set the .SelectedValue to a default of 0 ... your choice of default may differ depending on your app.
>>
>>~~Bonnie
>>
>>
>>
>>
>>>I have a stored procedure which returns a distinct list of categories. I call it via a strored proc and bind the DS to a combo.
>>>
>>>Problem is, once the user selects an item in the combo, there's no way to choose nothing. There's no empty row. Initially I have set the combo's SelectedIndex to -1, but that doesn't allow the user to unselect the selected item in the combo.
>>>
>>>Anyone?
Bonnie Berent DeWitt
NET/C# MVP since 2003

http://geek-goddess-bonnie.blogspot.com
Previous
Reply
Map
View

Click here to load this message in the networking platform