[CLOSED] Combobox, select first item

  1. #1

    [CLOSED] Combobox, select first item

    Hi,
    I have a Combobox inside of a window, which is implemented as a user control.
    ComboBox is declared this way:
    <ext:ComboBox runat="server" ID="absenceCb" FieldLabel="Absence" AnchorHorizontal="100%" EmptyText="no selection" />
    To fill the combo, I do the following in codebehind of user control:
    protected void Page_Load(object sender, EventArgs e)
            {
                if (!ExtNet.IsAjaxRequest)
                {
                    var types= repository.GetTypes(); 
                    types.ForEach(x => absenceCb.Items.Add(new ListItem(x.Name, x.Id.ToString(CultureInfo.InvariantCulture))));
                }
            }
    How can I select the first item of a combobox to be selected in my combo, when I Show the window(user control)?
    I tried to accomplish this with SelectedIndex="0" at markup, and by setting SelectedItem of a combobox in codebehind, but without any success.
    Last edited by Daniil; Nov 28, 2011 at 12:11 PM. Reason: [CLOSED]
  2. #2
    Hi,

    Please clarify how do you show a user control?

    Could you provide a full sample to reproduce the problem?
  3. #3
    Hello Daniil,
    it was an error in my code, which has nothing to do with the ComboBox itself.
    Please mark as closed, or even remove this thread.

    Quote Originally Posted by Daniil View Post
    Hi,

    Please clarify how do you show a user control?

    Could you provide a full sample to reproduce the problem?

Similar Threads

  1. Replies: 10
    Last Post: Apr 18, 2016, 6:26 AM
  2. [CLOSED] How to select a ComboBox item by value?
    By vadym.f in forum 1.x Legacy Premium Help
    Replies: 3
    Last Post: Apr 16, 2012, 4:15 PM
  3. I can not select any item in combobox
    By marco.amusquivar in forum 1.x Help
    Replies: 1
    Last Post: Mar 21, 2012, 8:09 PM
  4. Replies: 0
    Last Post: Sep 20, 2010, 8:56 PM
  5. Select a item in a Combobox
    By eliezer in forum 1.x Help
    Replies: 1
    Last Post: Apr 16, 2009, 12:23 PM

Posting Permissions