ComboBox Default Selection

  1. #1

    ComboBox Default Selection

    I'm populating a ComboBox from a database query in my Page_Load() I can create a special ListItem just for the first row in the returned query.

    Basically, my question is this: Is there a method to automatically select a ListItem in the ComboBox control?
  2. #2

    RE: ComboBox Default Selection

    I've resolved this problem on my own. For those out there who may still have an issue with this functionality, here's the solution:

    DataTable dt = new DataTable();
    dt.Load(mySqlDataReader);
    
    List<Coolite.Ext.Web.ListItem> items = new List<Coolite.Ext.Web.ListItem>();
    
    int i = 1;
    
    foreach (DataRow da in dt.Rows)
    {
        object[] array = da.ItemArray;
    
        if (i == 1)
        {
            comboSelectAccount.SelectedItem.Value = array[0].ToString();
        }
    
        items.Add(new Coolite.Ext.Web.ListItem(array[1].ToString(), array[0].ToString()));
    
        i++;
    }
    
    comboSelectAccount.Items.AddRange(items);

Similar Threads

  1. ComboBox default value with razer
    By zhdl in forum 2.x Help
    Replies: 0
    Last Post: Aug 13, 2012, 8:59 AM
  2. Replies: 0
    Last Post: Jul 27, 2012, 7:37 PM
  3. Wrong default value in comboBox?
    By flormariafr in forum 1.x Help
    Replies: 4
    Last Post: Jan 26, 2010, 10:12 PM
  4. [CLOSED] can the combobox in gridpanel appear by default?
    By LeeTheGreek in forum 1.x Legacy Premium Help
    Replies: 1
    Last Post: Nov 08, 2009, 10:33 PM
  5. ComboBox - Add Default Item
    By Tbaseflug in forum 1.x Help
    Replies: 0
    Last Post: Feb 03, 2009, 3:26 PM

Posting Permissions