two-way data binding with dropdown

B

ba

I'm using asp.net 2.0 and am writing a webform using the formview
control.

The <%# Bind("") %> syntax makes sense for textboxes, but I cannot
figure out how to bind a dropdown list to a column.

The values to be entered from the dropdownlist are YES and NO. I want
the source of the dropdown to be one of these two choices.

When the record is in 'edit mode', I want the dropdown list selected
value to be what it is in the record. Then when the user changes the
value (or not), it is bound to that column and the update takes place.

I get close with:
<asp:DropDownList ID="ddlProduct_Active" runat="server"
DataValueField="Product_Active" DataTextField="Product_Active"
SelectedValue = '<%# Bind("Product_Active") %>'
DataSourceID="SqlDataSource1">
</asp:DropDownList>

However, the above causes ALL the records in the dataset to have their
values displayed in the dropdownlist (lots os YES and NO). I just want
YES and NO as the only two values

I tried making a business object for the datasourceid and in that object
creating a data table, but did not do the trick.


Appreciate any tips.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,995
Messages
2,570,230
Members
46,816
Latest member
SapanaCarpetStudio

Latest Threads

Top