Hi,
I have a webdropdown with loadondemand enabled and enableautofiltering set to server. The datasource for the control is a datatable with 4000+ items.
I assign the datasource on every postback but i only do a databind when the page loads for the first time.
Load on demand works fine, but when i select an item that's further in the list, the selection is lost after a postback and jumps to the first visible item in the list. Is there a workaround for this behaviour?
I use netadvantage v2010.3
Sample code to reproduce the behaviour
<form id="form1" runat="server"> <asp:ScriptManager ID="ScriptManager1" runat="server" EnablePageMethods="True"> </asp:ScriptManager> <ig:WebDropDown ID="WebDropDown1" runat="server" EnableLoadOnDemand="True" Width="200px" EnableAutoCompleteFirstMatch="False" EnableAutoFiltering="Server" PageSize="10"> </ig:WebDropDown> <asp:Button ID="Button1" runat="server" Text="Button" /> </form>
Partial Public Class _Default Inherits System.Web.UI.Page Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load Dim dt As DataTable If Session("dt") Is Nothing Then dt = New DataTable("personen") dt.Columns.Add("userid", GetType(System.String)) Dim dr As DataRow Dim j As Integer = 100 For i As Integer = 1 To 4000 dr = dt.NewRow dr.Item("userid") = i dt.Rows.Add(dr) Next Else dt = CType(Session("dt"), DataTable) End If Me.WebDropDown1.DataSource = dt Me.WebDropDown1.TextField = "userid" Me.WebDropDown1.ValueField = "userid" If Not Me.IsPostBack() Then Me.WebDropDown1.DataBind() End If End Sub Protected Sub Button1_Click(ByVal sender As Object, ByVal e As EventArgs) Handles Button1.Click Dim test As String = Me.WebDropDown1.SelectedItem.Text End SubEnd Class
Before postback:
After postback:
Any tips?
Thanks in advance!!
screenshot before postback:
Screenshot after postback:
No one?
Hi there,
You are calling a DataBind method on page_load. You have to restore your selected state because the WDD cannot determine whether you are calling this DataBind with a new data source or not and we wouldn't want persisted selection when data sources change. For example you can store the selected index in a session variable and set this selected index after the databinding has been performed?
Let me know if this helps!
Has this issue already got fixed? or I still need to restore my selected item in my code? Thanks.
I am in this bucket now.
Currently I am using 12.1 version of webdrowdown. I have placed webdropdown in edittemplate of gridview control and binding this onrowbound of gridview, also we are selecting selected items form db incase of available.
Now I have this dropdown in one of the column of gridview control, i can select multiple items and click save it saves as expected, but i have button in another column when I click that it performs autopostback and populate the one text box value.
now the problem is.
after selecting values for webdropdown if click on button i see null value for selected item for webdropdown while saving. I cannot use the suggestion onclick save to session becuase each time it goes to postback.
All right, it looks that this issue has been fixed in NetAdvantage 2012.