B
Brian
I have an ASP.NET page that uses a FormView and SqlDataSource. Within my
page I want to change a string if a column within my database record is a
certain value. Here is some sample code:
<asp:Content ID="Content2" ContentPlaceHolderID="Main" Runat="Server">
<asp:FormView ID="FormView1" runat="server" Width="123px"
DataKeyNames="property_key" DataSourceID="SqlDataSource1">
<ItemTemplate>
<strong style="font-size: 12px">For Sale</strong>
</ItemTemplate>
</asp:FormView>
<asp:SqlDataSource ID="SqlDataSource1" runat="server" ConnectionString="<%$
ConnectionStrings:MyDatabase %>"
SelectCommand="SELECT * from property_info WHERE property_key =
@property_key">
<SelectParameters>
<asp:QueryStringParameter DefaultValue="0" Name="property_key"
QueryStringField="id"
Type="String" />
</SelectParameters>
</asp:SqlDataSource>
</asp:Content>
I know how to use "Eval" to display values from the current database record
but I want to do is change the "For Sale" string to "For Rent" when a
database column is a certain value. I wasn't sure if this would be better
handled with C# code behind - and just use a placeholder or if I should use
code within the page. I'd almost prefer to use a place holder but I'm not
sure how to access to current database record from the C# code behind. Or
if this should be handled within the page, I don't know the syntax to do a
conditional statement here. Ever tried searching MSDN for "conditional
statement ASP.NET"? Please excuse my ignorance but I haven't done much
ASP.NET work.
Any suggestions would be greatly appreciated.
TIA
Brian
page I want to change a string if a column within my database record is a
certain value. Here is some sample code:
<asp:Content ID="Content2" ContentPlaceHolderID="Main" Runat="Server">
<asp:FormView ID="FormView1" runat="server" Width="123px"
DataKeyNames="property_key" DataSourceID="SqlDataSource1">
<ItemTemplate>
<strong style="font-size: 12px">For Sale</strong>
</ItemTemplate>
</asp:FormView>
<asp:SqlDataSource ID="SqlDataSource1" runat="server" ConnectionString="<%$
ConnectionStrings:MyDatabase %>"
SelectCommand="SELECT * from property_info WHERE property_key =
@property_key">
<SelectParameters>
<asp:QueryStringParameter DefaultValue="0" Name="property_key"
QueryStringField="id"
Type="String" />
</SelectParameters>
</asp:SqlDataSource>
</asp:Content>
I know how to use "Eval" to display values from the current database record
but I want to do is change the "For Sale" string to "For Rent" when a
database column is a certain value. I wasn't sure if this would be better
handled with C# code behind - and just use a placeholder or if I should use
code within the page. I'd almost prefer to use a place holder but I'm not
sure how to access to current database record from the C# code behind. Or
if this should be handled within the page, I don't know the syntax to do a
conditional statement here. Ever tried searching MSDN for "conditional
statement ASP.NET"? Please excuse my ignorance but I haven't done much
ASP.NET work.
Any suggestions would be greatly appreciated.
TIA
Brian