Categories: MSDN / DotNet / Java / Scripts / Linux / PHP Ask - La ask - La Answer

Dropdownlist missing value??

I have a dropdownlist on a two-way data binding formview. How can I change selected index to 0 or disabled the dropdownlist when the bound selectedvalue "data_field " is missing from the list items "value_item"? Following is the code:

formview: <asp:FormView ID="fvwTest" DataSourceID="odsFV">
...
<EditItemTemplate>
...
<asp:DropDownList ID="ddl" SelectedValue='<%# Bind("data_field")%>' Runat="server" DataSourceID="ods" DataValueField="value_item" DataTextField="text_item" />
<asp:ObjectDataSource ID="ods" Runat="server" TypeName="test" SelectMethod="GetTestData"/>
...
</EditItemTemplate>
...
</asp:FormView>
<asp:ObjectDataSource ID="odsFV" Runat="server" TypeName="test" SelectMethod="GetTestDataFV"/>

The SelectedValue data_field is coming from the FormView datasource SelecteMethod GetTestDataFV.
[936 byte] By [JFeng] at [2007-11-11 8:14:56]