PDA

View Full Version : MultiSelect - Pre Selecting items



3 Mar 2010, 4:32 PM
I am having a frustrating time with a user control and the ext:MultiSelect object.

I have an ext:Window within the control that is displayed when the user clicks a button.

Within this Window is a DataBound ext:MultiSelect. I want to pre-select the first item in this control, but in every method I have tried, the Items collection is empty, which means I have no way to know what the first item in the list is.

When the window is displayed, the values are there, and when the window is submitted, the SelectedItems collection is working fine, but the Items collection is always empty.

I have tried adding a SelectedItem object to the control in the Init, Load and PreRender methods, and the button click event itself, and in every case there is nothing in the Items collection.

I have tried adding new SelectedItem objects with values of 0 (index) and "All" (first item in the list). Nothing.

This is the code I have been trying to get to work:

By Value


msChosen.SelectedItems.Add(new SelectedListItem("All"));


or
By Index


msChosen.SelectedItems.Add(new SelectedListItem(0));


or
By Object


msChosen.SelectedItems.Add(new SelectedListItem(msChosen.Items[0].Text));


and a few others.

This shouldn't be that hard to do.

Help Please!