Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
How to re-bind the combobox?
Message
 
 
To
19/05/2009 13:52:01
General information
Forum:
ASP.NET
Category:
Coding, syntax and commands
Environment versions
Environment:
C# 3.0
OS:
Windows XP
Network:
Windows 2003 Server
Database:
MS SQL Server
Miscellaneous
Thread ID:
01400729
Message ID:
01400749
Views:
31
Sylvain,

The first time the selected item is 'Select Category', but then it could be any category. However, it seems like I can only select category once to get the Items displayed correctly - every time I select anyhing else it remains the same - it should clear the Items combo value and allow me to select items for the selected category - this part I can not get to work as hard as I already tried.

I'll move the handler to the private method - good point.

>Isn't SelectedItem == "Select Category" only true the first time around?
>
>BTW, I see two design flaw in this code:
>1) Hard coded "Select Category". What if the text change later? Internationalized?
>2) No code shoud be in event handlers. cboCategories_SelectedIndexChanged should call a private method.
>
>>I have the simple problem - two related comboboxes. One to select Category and another to select items by Category. I can not get it to work - it seems to only work the first time.
>>
>>Do you see where is my problem in this code?
private void cboCategories_SelectedIndexChanged(object sender, EventArgs e)
>>        {
>>            string SelectedItem = this.cboCategories.Text.Trim();
>>            if (SelectedItem != "Select Category")
>>            {
>>                this._inventoryEntries = _inventoryBiz.GetInventoryDictionaryByCategory(SelectedItem);
>>
>>                foreach (KeyValuePair<string, string> kvp in this._inventoryEntries)
>>                {
>>                    this._inventoryList.Add(kvp.Key);
>>                }
>>                this.cboItems.Enabled = true;
>>                this.cboItems.DataSource = this._inventoryList;
>>            }
>>            else
>>                this.cboItems.Enabled = false; 
>>        }
If it's not broken, fix it until it is.


My Blog
Previous
Next
Reply
Map
View

Click here to load this message in the networking platform