Hi There
I have a webdropdown that is bound to a sql dataset to populate its items. When the dropdown is opened it will not select the first item in the list. If any other item is selected first then the initial item is reselected it will select OK. Code as follows:
<ig:WebDropDown ID="WebDropDownPrincipalID" runat="server" Width="150px" DropDownAnimationType="Linear" DropDownContainerHeight="0px" DropDownContainerMaxHeight="0px" DropDownContainerWidth="0px" StyleSetName="Trendy" onitemsrequested="WebDropDownPrincipalID_ItemsRequested"> <clientevents focus="wddOpening" /> </ig:WebDropDown>
function wddOpening(sender, e) { sender.loadItems(); }
I have investigated this at length and cannot see what is going on.
Any suggestions??
Hi,
Thanks very much for your input. What code do you have in the ItemsRequested handler on the server-side? I am using this code in my handler, and i can select the first item, when items are loaded:
protected void WebDropDown1_ItemsRequested(object sender, Infragistics.Web.UI.ListControls.DropDownItemsRequestedEventArgs e)
{
this.SqlDataSource1.SelectCommand = string.Format("SELECT * FROM Products WHERE ProductName LIKE '{0}%'", e.Value.ToString().ToLower());
this.WebDropDown1.DataSource = SqlDataSource1;
this.WebDropDown1.DataBind();
}
The ASPX code and javascript client-side event handler I am using is the same as in your example above.
P.S: I am selecting the item with the mouse, not using the API (server or client-side) - if this could make a difference.
Thanks,
Angel
In fact if you have EnableAutoCompleteFirstMatch="true" (it is true by default), on the postback to load the initial items (assuming the dropdown is empty initially), it will automatically select the first item on the server, because it will think it matches the input string. You can avoid this behavior by setting EnableAutoCompleteFirstMatch to "false".
On the other hand, if you feel this is a bug, I can submit an internal request for further evaluation.
Thanks again for the feedback,
Hi Angel
Thanks for your replies. Autocpmpletefirstmatch is true ( I have even tried it false to no avail)
I did not actually have the databind command in my codebehind but adding it has made no changes. I am the newbie round here so am regularly just "trying it and living in hope!! " -- Anyway here is the code behind the itemsrequested event. I am not a database expert but I am told that this is how we must setup our datasources as we are using row level security in the database therefore must have web methods providing the dataset and not direct sql queries.
protected void WebDropDownPrincipalID_ItemsRequested(object sender, Infragistics.Web.UI.ListControls.DropDownItemsRequestedEventArgs e) { DataSet ds = IMSCommon.getCompanies(IMSCommon.IMS_COMPANYTYPE.Principal); if (ds != null && ds.Tables.Count > 0) { this.WebDropDownPrincipalID.DataSource = ds.Tables[0]; this.WebDropDownPrincipalID.ValueField = "ID"; this.WebDropDownPrincipalID.TextField = "FullName"; this.WebDropDownPrincipalID.DataBind(); }
This is how all wdd on my form are set up and they all have the same fault. Is there maybe a better way to do this??
thanks
Brendan
Hi Brendan,
The code looks perfectly fine in my opinion and should work. Can you describe in more detail what happens when you try to select the first item? Does its Style change? Or it's like kind of disabled?
P.S: If you can assemble some sample WebSite or solution project demonstrating this issue, i will be more than willing to take a look and make the necessary adjustments so that it works - unless it appears to be a bug in the control.
Hi Again
The process is as follows.
The wdd in question is Principal. Shot 1 shows nothing selected on a newly refreshed page
Shot 2 the first item in the list is chosen then the dropdown will close but the item will not show in the text area
Shot 3 the dropdown can then be opened again and the first item is shown in the style as selected but still not shown in the text area.
If the second item in the list is selected it will show perfectly and now the first item can be selected and will show as normal.
????????????
Thanks in advance