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
575
WebDropDown loses items after postback
posted

I've a problem with a WebDropDown with NetAdvantage 11.2.

I'm binding a DataTable to a WebDropDown, setting the ItemTemplate as shown in the demo video by Craig Shoemaker:

<ig:WebDropDown runat="server" ID="cboTest" TextField="Code" ValueField="Code" AutoPostBackFlags-ValueChanged="On" EnableViewState="true">

     <ItemTemplate>

         <%# DataBinder.Eval(Container.DataItem, "Code")%>: <%# DataBinder.Eval(Container.DataItem, "Description")%>

            </ItemTemplate>

</ig:WebDropDown>

In the code behind the dropdown is populated in the OnClick event of a button:
Protected Sub btnNewElement_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles btnNewElement.Click
    Me.cboTest.DataSource = dtArticles
    Me.cboTest.DataBind()
    Session(" dtArticles") = dtArticles
End Sub
The problem is that, when I choose an element from dropdown and postback occurs:
- if I use only the code shown above, the selected item is correctly chosen (CurrentValue has the expected value), but when I open the dropdown afted a ValueChanged postback all the elements are blank. Note: items in the dropdown are still there and I can select any other item, text and value are correctly set, but I can't see what item I'm clicking on...
- if I add a rebind (set DataSource from the session object and call DataBind()) in the Page_Load event, after the postback all the items are correctly shown, but the CurrentValue is always Nothing and the selected item (== the text shown in the dropdown) is always set as the first element of the dropdown.
Enabling or disabling ViewState of the dropdown doesn't seem to change things.
Any hint?