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 Angel,
Thanks for the reply.
I've tried updating the WebDropDown several ways;
However by WebDropDown is not bound to any data, I simply populate the WebDropDown at runtime using a loop that adds the numbers from 1 to the maximum page number. For example;
For iCount As Integer = 1 To totalPageNumbers WebDropDown.Items.Add(New Infragistics.Web.UI.ListControls.DropDownItem(iCount, iCount))Next
Should I be binding the WebDropDown to a datasource to allow setting SelectedValue to work? If so, I'll try binding to an array of page numbers.
Thanks,
Ian.
Hi walles,
When you click "Previous", how do you update the CurrentValue? CurrentValue is just the Text shown in the input. When you change it, it won't affect the selection.
I suggest to either Bind the Value field to the same data (page number), and setting SelectedValue instead - it will automatically update both the selection and the Text (CurrentValue) - as it is in Microsoft's DropDownList.
Additionally, if you still want to use the CurrentValue, you can manually find the new selected item and set it to Selected. (again, using the SelectedValue should be the better approach).
The purpose of CurrentValue is when we have auto-suggest filtering functionality, and the user can freely type anything in the input box - then we don't have 1:1 correspondence between "current" input value, and Selected item's Text.
Please let me know if this helps and how i can help further.
Angel
I'm also having difficulty setting the selected item of the WebDropDown. The display mode for my list is DropDownList. The WebDropDown is part of a User Control that is used as a pagination control, therefore the list simply contains a list of numbers from 1 to the total number of pages available. The User Control also contains Buttons to move forwards or backwards through the pages. I'm trying to update the WebDropDown when one of these pages is clicked so that the list in the WebDropDown corresponds to that page being viewed.
Using the above code that sets the CurrentValue works partially - when the buttons are clicked the value displayed in the WebDropDown changes accordingly, however when the WebDropDown is selected and the entire list shown, the highlighted ListItem does not match the CurrentValue.
For example, if I select the WebDropDown and then select page 4, the fourth page is displayed and the number 4 becomes highlighted. If I then select the "Previous" Button, the page changes and the value displayed in the collapsed WebDropDown changes to 3. If I then select the WebDropDown and the full list is displyed, the ListIem 4 remains highlighted in the list, when ideally it should be the ListItem 3 that is highlighted.
Any help would be greatly appreciated.
Thanks.
Hello,
Thanks again, i am very happy the scenario works fine now. All your feedback is greatly appreciated. About the DataBind() call - i will investigate further why this needs to be called and if it apperas to be a bug - we will file an issue.
Hello Angle,
Do you also add to the bug report that I have to re-bind the control before I do a FindItem eventho its bound to a SqlDataSource that is on the form ? Here is the final codebehind I have to use to restore the database item. dr is a datarow.
Thanks for all the help on this.
IndustryDdl2.DataKeyFields = "IRecId"IndustryDdl2.TextField = "IndustryName"IndustryDdl2.ValueField = "IRecId"IndustryDdl2.DataBind()
If IndustryDdl2.Items.FindItemByValue(dr("IndustryId")) IsNot Nothing Then IndustryDdl2.CurrentValue = "" IndustryDdl2.SelectedValue = dr("IndustryId")End If