Nov 27, 2011, 11:36 PM
[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:
I tried to accomplish this with SelectedIndex="0" at markup, and by setting SelectedItem of a combobox in codebehind, but without any success.
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]