FormView binding to boolean property

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

  1. working from Dino Esposito's book on asp.net 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?

    thanks,


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

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

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

    <tr>
    <td bgcolor="yellow" width="50px" align="center">
    <b>Is shipping</b>
    </td>
    <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"/>

    </td>
    </tr> </table>
    </ItemTemplate>
    </asp:FormView>
    Steve Richter, Nov 23, 2008
    #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. Alan Silver
    Replies:
    6
    Views:
    2,893
    Alan Silver
    Jul 13, 2005
  2. TS
    Replies:
    3
    Views:
    2,469
  3. Chris

    Formview within Formview

    Chris, May 19, 2007, in forum: ASP .Net
    Replies:
    0
    Views:
    522
    Chris
    May 19, 2007
  4. J Leonard
    Replies:
    4
    Views:
    12,671
    Mark Space
    Jan 19, 2008
  5. Metre Meter
    Replies:
    7
    Views:
    367
    Metre Meter
    Aug 6, 2010
Loading...

Share This Page