5
Answers

Combobox does not display selected item

Avuya Mxoli

Avuya Mxoli

13y
1.8k
1
Hi,
I have a combobox of countries which I loaded in collections property. When I select a country I want the details to be displayed on a gridview but when I select nothing gets returned back to me..I hope this makes sense. I havent set the selectedIndex to anything plz help anyone,Thanks.


Answers (5)
0
Prabhu Raja
NA 4.7k 1.5m 13y
Nice Mxoli...
0
Avuya Mxoli
NA 236 145k 13y
Thanks this got solved when I solved another error I had with a class
0
Avuya Mxoli
NA 236 145k 13y
Prahbu it means nothing gets returned to the user i.e it returns blank on the space where its supposed to return what the user selected. Hope it makes sense, thnks
0
Tulasi
NA 1.5k 152.4k 13y
Hi ncedisa Mxoli,
           1)make sure ur combobox will be binded  in the following  way 
                protected void Page_load(Object sender,EventArgs e)
                {
                     if(!IsPoatback) 
                      {
                                   //write code to bind combobx
                        }
                }
          
            2) write the following  code in SelectedindexChangedEvent  
                    
                    
 if (drp.SelectedItem.Text!="Select")   
                    {
                           //code to bind  information to gridview
                     }
                    else
                     {
                      //dispaly message no country is selected
                   }
 Please do not forget to mark "Accpeted Answer".

0
Prabhu Raja
NA 4.7k 1.5m 13y
Hi,

 I can't understand, "gets returned back to me" in your post. but i suggest you, select a item by default when form gets loaded.

 Example:

            In form_Load() Event, 
 
            If ( this.combobox1.items.Count >0) then
                      this.combobox1.selectedIndex = 0;