Wrox Home  
Search P2P Archive for: Go

  Return to Index  

aspx_professional thread: Databind() clears contents of dropdownlist


Message #1 by mmanley@n... on Fri, 7 Jun 2002 15:56:06
I have wired a sub procedure to the onSelectedIndexChanged event of a 
dropdownlist. When I call Databind() it appears to clear the contents of 
the dropdownlist when the page reloads. My code is as follows:

<asp:DropDownList 
ID="product" 
Runat="server" 
onSelectedIndexChanged="ChangeVersions" 
AutoPostBack="True" 
DataSource='<%#BindProducts()%>' 
DataTextField="PRODUCTDESC" 
DataValueField="PRODUCTDESC" 
SelectedIndex='<%# GetProductIndex(DataBinder.Eval
(Container.DataItem, "product"))%>' />

Sub ChangeVersions(ByVal sender As Object, ByVal e As System.EventArgs)
        Dim oVersion As DropDownList = CType(sender.FindControl
("version"), DropDownList)
        oVersion.DataTextField = "VERSIONDESC"
        oVersion.DataValueField = "VERSIONDESC"
        oVersion.DataSource = BindVersions(sender.SelectedItem.Value)
        oVersion.DataBind()
End Sub

I can get and set other properties on the oVersion object 
(oVersion.SelectedItem.Value, etc). I have also verified I'm getting a 
valid dataview object from the BindVersions function. Why can I do 
everything but successfully call Databind()?

Any help with this would be appreciated. Thanks. 

Matt					

  Return to Index