Hello again....
I have a a WebDropdown that has been loaded with data from a table. What are the properties that I need to use to get and restore the selected item in the WebDropdown.
Hi,
The selected item is automatically stored in the SelectedItem WebDropDown property. If you have EnableMultipleSelection=true, you need to use the SelectedItems collection :
1)
WebDropDown1.SelectedItem
2)
WebDropDown1.SelectedItems
You do not need any special code / logic to store and restore the selection across postbacks - it is done automatically.
In order to set an Item as selected, you can do :
WebDropDown1.Items[0].Selected = true; // this will mark the first item as selected
For single selection you can also do :
WebDropDown1.SelectedItem = item;
Thanks,
Angel
Here is the code for th control. I still cant get it to restore the selected item from the saved value field that was saved in the database. I was Using WebCombo. I used [ControlName].DataValue to get the IRecId and [ControlName].FindByValue([Var int32]).Selected = True to restore the IRecId data. These properties are not in WebDropDown.
<ig:WebDropDown ID="IndustryDdl2" runat="server" AutoFilterResultSize="30" AutoFilterSortOrder="Ascending" DataKeyFields="IRecId" DataSourceID="dsIndustries" DropDownAnimationType="Linear" DropDownContainerHeight="50px" DropDownContainerMaxHeight="100px" DropDownContainerWidth="150px" EnableDropDownAsChild="True" Height="18px" MultipleSelectionType="Checkbox" PageSize="0" TextField="IndustryName" ValueField="IRecId" Width="150px" DropDownAnimationDuration="250"><DropDownItemBinding TextField="IndustryName" ValueField="IRecId" /><Button ImageUrl="~/Images/WDdl.gif" pressedimageurl="~/Images/WDdl_Up.gif" /></ig:WebDropDown>
Hi Angel,
Before I contact Development Support I was wondering if you can have a look at my control? I've attached a demo project containing the control, though I had to remove the ig_res directory as it forced the attachment to exceed the upload limit.
Once the project is up and running, using the dropdown select a page number, this will become highlighted. Then if you select one of the buttons, the displayed value will change in the dropdown (good), though if you select the dropdown (displaying the full list) you'll notice the highlighted item doesn't change to match the displayed value.
Is this a bug? Or am I incorrectly modifying the dropdown in my code?
Ian.
Hi Ian,
Thanks for the sample. First thing i notice is that you use the original initial release build 1015. Please upgrade to the latest service release where the issues you are facing should be fixed.
I've updated to the latest service release and the issue I have is still persisting.
To expand on my last post, if you use the buttons without selecting an item in the dropdown (via the mouse) then the highlighting changes to match the number displayed in the collapsed dropdown - this is a grey highlighting. If you select an item using the mouse, this is highlighted in blue and it does not change when a button is pressed and you end up with 2 separate highlighted numbers, a grey and a blue - the grey matches the number in the collapsed dropdown and the blue stays on whatever was last selected by the mouse.
Hope that makes sense?
Yep, it makes perfect sense to me:) There was an internal issue reported about a similar behavior, the number is 22103, one thing that is possible is that it didn't get into the latest service release.
By the way, the "gray" style for the Default StyleSet is for the Selected style , while the blue one is for Active item style, i.e. if an item is both selected and active, it will have blue style ,because it will be applied over the gray one.
Thanks for the reply. Your 2nd paragraph gave me an idea, I have resolved the issue by manipulating the style set (in the CSS) for each of the ListItem states and that has allowed me to achieve the "look and feel" that I want. Essentially I just apply a style to the ListItemDisabled (current page) and the ListItemHover. Works nicely.
Before doing that I did attempt to set "Activated" when setting the selected value (activating the corresponding item in the list) and this raised an exception from the WebDropDown - "Object reference not set ....". You may want to pass this on.
Thanks, i will investigate.