Click here to Skip to main content
15,904,655 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
I have retrieve values from database whicc consists of two price column in it one from "Product" and one from "Store_Product" tables.

So when binding a label's text with the retrieved values, I want to set it to Store_Product.Price value if it is there otherwise I have to Set Product.Price value. I have:

C
<asp:Label ID="lblPrice" runat="server" Text='<%#Bind("price")>'%>
Posted
Updated 9-May-11 11:11am
v4
Comments
Sandeep Mewara 9-May-11 6:56am    
Not sure what are you looking for? Did you try? for now it's a problem statement - try out and be a little more specific.

I would do this in code inside what you are binding to
(an object, or data set etc) and set "price" to whatever price you want.

This is business logic and shouldn't be in your view
 
Share this answer
 
You should either:
1) Set Price in the code that populates the data from the database with the value you want to use and bind it.
2) In the object you are binding two, have the price property work out which value to display.

in either case you might find the following useful, though you will have to adapt it:


C#
decimal valueToUse = Store_Product.Price > 0 ? Store_Product.Price  : Product.Price;


Assuming you haven't used nullable types.
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900