Your Privacy Matters: We use our own and third-party cookies to improve your experience on our website. By continuing to use the website we understand that you accept their use. Cookie Policy
280
keep selected item after postback
posted

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 Sub

End Class

Before postback:

After postback:

Any tips?

 

Thanks in advance!!