FormView binding to boolean property

S

Steve Richter

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>
 

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

Forum statistics

Threads
473,767
Messages
2,569,572
Members
45,046
Latest member
Gavizuho

Latest Threads

Top