FormView binding to boolean property

Discussion in 'ASP .Net' started by Steve Richter, Nov 23, 2008.

  1. working from Dino Esposito's book on 3.5, he has a great example of a
    FormView binding to the selected row of a GridView.

    my "GetVendor" method returns a class that contains Vendor properties. One
    of the properties is a boolean that indicates if the drop ship vendor is
    currently shipping the items in a catalog.

    How do I bind that boolean property to a RadioButton or RadioButtonList with
    a "yes" button and a "no" button? The first problem is getting the "no"
    button to be on when the boolean is false. My class has an "IsShipping"
    property. I created a 2nd property called "IsNotShipping" that the "no"
    button binds to. Is there a better way?


    <asp:ObjectDataSource id="RowDataSource" runat="server"
    SelectMethod="GetVendor" TypeName="Data_Vendors" >
    <asp:ControlParameter Name="FactCode" ControlID="GridView2"
    PropertyName="SelectedValue" />

    <asp:FormView ID="FormView1" runat="server"
    DataKeyNames="FactCode" DataSourceID="RowDataSource" >

    <table style="border:solid 1px black;" width="100%">

    <td bgcolor="yellow" width="50px" align="center">
    <b>Is shipping</b>
    <td bgcolor="lightyellow" >

    <asp:RadioButton ID="shippingYes" GroupName="IsShip" Text="Yes"
    Checked='<%# Bind("IsShipping") %>' runat="server"/>
    <asp:RadioButton ID="shippingNo" GroupName="IsShip" Text="No"
    Checked='<%# Bind("IsNotShipping") %>' runat="server"/>

    </tr> </table>
    Steve Richter, Nov 23, 2008
    1. Advertisements

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 (here). After that, you can post your question and our members will help you out.