I am using a WebDropDown in multiple selection mode and adding items manually in my Page_Load event.
When the page loads, the first item in the list is always automatically selected. I can not find a way to turn this off.
During a postback, the correct items remain selected/deselected, it's just that when my page is first loaded, the first item is preselected.
I need to have no items selected on first page load.
Hello,
I was not able to see the first item selected using NetAdvantage version 12.1.20121.2072 and IE 9. I used below HTML mark up and code to test this:
HTML MarkUp:
<ig:WebDropDown ID="WebDropDown1" runat="server" Width="200px" EnableMultipleSelection="True"> </ig:WebDropDown>
Code:
DropDownItem wd = new DropDownItem(); wd.Text = "First"; wd.Value = "1"; this.WebDropDown1.Items.Add(wd);
DropDownItem wd1 = new DropDownItem(); wd1.Text = "Second"; wd1.Value = "2"; this.WebDropDown1.Items.Add(wd1);
If you want to clear selected items explicitly on page load, I would suggest you to use SelectedItems.Clear(); method as shown below:
if (!IsPostBack)
this.WebDropDown1.SelectedItems.Clear();
I hope this helps.
Bhadresh,
Here is a sample using .NET 3.5 and Infragistics version 12.1.20121.2020.
This sample demonstrates exactly what I am talking about.
When the page loads on the client, the first item is automatically selected.
When I check in the Page_LoadComplete() event on the server, there are zero selected items.
wvusaf
Well, i'm using version 12.1.20121.2020 and IE 8 in Windows XP. dont know if this makes some sort of difference or not.
but, anyway, i am adding items in code just as you mentioned. i also tried unselecting all items in the code behind too, but when i debug, at that point in the code, there are no selected items.
it's only when the page is rendered on the client that the WDD value is set and the first item is checked. i don't know where/how it's happening but the only way i could 'fix' it is to use this client event:
function DropDownInitialize(sender, args) {
if(<%=(Not Page.IsPostBack).ToString().ToLower()%>){
sender.set_currentValue('', true);
sender.get_items().getItem(0).unselect();
}