two-way data binding with dropdown

Discussion in 'ASP .Net' started by ba, Aug 16, 2005.

  1. ba

    ba Guest

    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.
    ba, Aug 16, 2005
    #1
    1. Advertising

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

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Darrel
    Replies:
    2
    Views:
    567
    Darrel
    Dec 6, 2004
  2. AM

    Dynamic two-way data binding

    AM, Apr 21, 2006, in forum: ASP .Net
    Replies:
    0
    Views:
    539
  3. Larry Bud

    Two-way Custom data binding

    Larry Bud, Apr 27, 2007, in forum: ASP .Net
    Replies:
    2
    Views:
    414
    Page Brooks
    Apr 30, 2007
  4. EricLondaits
    Replies:
    0
    Views:
    597
    EricLondaits
    May 9, 2007
  5. Mike Milian
    Replies:
    0
    Views:
    336
    Mike Milian
    Apr 14, 2008
Loading...

Share This Page