Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
How to re-bind the combobox?
Message
De
23/05/2009 18:28:24
 
 
Information générale
Forum:
ASP.NET
Catégorie:
Code, syntaxe and commandes
Versions des environnements
Environment:
C# 3.0
OS:
Windows XP
Network:
Windows 2003 Server
Database:
MS SQL Server
Divers
Thread ID:
01400729
Message ID:
01401671
Vues:
47
This message has been marked as a message which has helped to the initial question of the thread.
>I want the Items combo to be blank when I select a different category. Unfortunately, it behaves this way - temporarily shows the item correspoding to the previously selected index and then goes blank. Any way to prevent wrong item to display?

I see in another post that you already figured this one out, changing
                this.cboItems.SelectedIndex = 0; //Start from the empty item
-to-
                this.cboItems.SelectedIndex = -1; //Start from the empty item
was what I was going to suggest. Just thought I'd reiterate in response to the post that asked the question, in case there are interested lurkers.

~~Bonnie




>>I think you're missing a this._inventoryList.Clear() before the foreach loop. Try also resetting cboItems.DataSource to null before the foreach loop.
>>
>>>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.
>
>There is a little problem with this code I'm not sure how to avoid:
>
>
>        private void RefreshItemsCombo() 
>        { 
>            string SelectedItem = this.cboCategories.Text.Trim();            
>            this._inventoryList.Clear();
>            this.cboItems.DataSource = null; 
> 
>            if (SelectedItem != "")
>            {                
>                this._inventoryEntries = _inventoryBiz.GetInventoryDictionaryByCategory(SelectedItem);
>                _inventoryList.Add("");
>
>                foreach (KeyValuePair<string, string> kvp in this._inventoryEntries)
>                {
>                    this._inventoryList.Add(kvp.Key);
>                }
>                this.cboItems.Enabled = true;
>                this.cboItems.DataSource = this._inventoryList;
>                this.cboItems.SelectedIndex = 0; //Start from the empty item
>            }
>            else
>                this.cboItems.Enabled = false;
>            
>        }       
>
>
>I want the Items combo to be blank when I select a different category. Unfortunately, it behaves this way - temporarily shows the item correspoding to the previously selected index and then goes blank. Any way to prevent wrong item to display?
>
>Thanks in advance.
Bonnie Berent DeWitt
NET/C# MVP since 2003

http://geek-goddess-bonnie.blogspot.com
Précédent
Répondre
Fil
Voir

Click here to load this message in the networking platform