This is a difficult dilemma for working on any webforms project. You have two options for the conditional formatting logic - on the page itself (now you should duplicate it throughout the site) or in some code, as you do. There are also no great options in terms of sharing problems; this is a well-known drawback of the ASP.Net web form model.
Personally, I would turn your view into a custom .ascx control that contains the FormView control and binds it to the apartment wrapper. Sort of:
<asp:FormView ID="FormView1" DataSourceID="ObjectDataSource1" RunAt="server"> <ItemTemplate> <table> <tr> <td align="right"><b>Rent:</b></td> <td><%# Eval("Rent") %></td> </tr> <tr> <td align="right"><b>BedsBathsSqFt:</b></td> <td><%# Eval("BedsBathsSqFt") %></td> </tr> </table> </ItemTemplate> </asp:FormView>
Have a .ascx, set the DataSource property so that it can be set on the page using it.
If the Databinding was more flexible with conditional expressions, you could remove the apartment wrapper object and paste the conditions directly into the user control. Despite the complexity of your properties, this is likely to be a big headache. However, you can see something like this where people tried to get around these restrictions.
source share