This looks like another bug in the WebDropDown.
When a WebDropDown is bound to a data source containing several items and the second item in the list is selected and then subsequently this dropdown is bound to a different data source containing only one item, the dropdown seems to be disabled and does not show any value.
This does not happen if any item other than the second in the dropdown is selected before the list is rebound. It also does not happen if the list is rebound to a data source with more that one item.
I have included some code to reproduce the problem: click the 'Set Three' button, select the second item and then click the 'Set One' button.
<form id="form1" runat="server"> <div> <asp:ScriptManager ID="ScriptManager1" runat="server" /> <ig:WebDropDown ID="WebDropDown2" runat="server" Width="224px" DisplayMode="DropDownList" TextField="second" ValueField="first" AutoPostBackFlags-SelectionChanged="On"><ClientEvents /></ig:WebDropDown><br /> <asp:Button ID="Button1" runat="server" Text="Set One" onclick="Button1_Click" /> <asp:Button ID="Button2" runat="server" Text="Set Three" onclick="Button2_Click" /> </div> </form> <script runat="server"> public class myObject { public myObject(string first, string second) { this.first = first; this.second = second; } public string first { get; set; } public string second { get; set; } } protected void Button1_Click(object sender, EventArgs e) { List<myObject> lTwo = new List<myObject>(); lTwo.Add(new myObject("1", "Not Set")); WebDropDown2.DataSource = lTwo; WebDropDown2.DataBind(); WebDropDown2.SelectedValue = WebDropDown2.Items[0].Value; } protected void Button2_Click(object sender, EventArgs e) { List<myObject> lTwo = new List<myObject>(); lTwo.Add(new myObject("1", "One")); lTwo.Add(new myObject("2", "Two")); lTwo.Add(new myObject("3", "Three")); WebDropDown2.DataSource = lTwo; WebDropDown2.DataBind(); WebDropDown2.SelectedValue = WebDropDown2.Items[0].Value; } </script>
Hi,
When i follow the steps you have described, after clicking on "Set One" button, I get the dropdown bound correctly and showing one item "Not Set" (it's not empty or disabled).
I am using latest code, could you check this scenario with the latest service release? Which build are you currently using?
Thanks for the feedback,
Angel
I believe I'm using the latest service release for .NET 3.5 - 9.1.20091.2067
I have just tried this in IE(v6) and it works. It does not work with firefox 3.5. I haven't tried any other browser versions.
Incidentally, the expandable tree control for the documentation part of your website does not work with firefox 3.5 either - it doesn't show a scroll bar so items towards the bottom are inaccessible. (http://help.infragistics.com/NetAdvantage/ASPNET/2009.1/CLR3.5/)
I managed to easily reproduce the issue you are encountering on FF, Chrome, and Opera.
Basically in the WebDropDown we use lazy loading of client-side objects -i.e. items are not created and added to collections until they are actually requested - for example on hover, on programatic retrieval, on selection. this lazy loading is enabled by default when AutoFiltering=Server or Off.
For EnableAutoFiltering=Client, we create all objects during init, since filtering on the client only will require them at once.
On these browsers there seems to be some issue with autopostback when items aren't initialized yet - under this specific circumstances you have described with number of bound items.
I have submitted a bug for this, for your reference the number is: 21173.
There is a workaround for this issue, for the FF and Chrome , and opera browsers: to access every item in some initialize event, which will ensure it is initialized (you can use this approach if it is urgent , before the fix appears in a service release):
function DropDown_Initialize(sender,args)
{
var items = sender.get_items();
for(i=0;i<items.getLength();i++)
items.getItem(i);
}
Hope it helps. Thanks,
Thanks for the response.
I couldn't get the DropDown_Initialize workaround to work but I have set EnableAutoFiltering="Client" and this seems to fix the problem for now.
I will install the service release when it becomes available.