Solved

Data Binding

Posted on 2011-09-08
4
270 Views
Last Modified: 2012-08-13
Hey guys, i am populating my grideview from my database and i need help how to bind my data.

i have this coloums in my table:  id, available, price  (some of my varables)

in my grideview i have a lable for price

<asp:Label ID="lblPrice" runat="server" Font-Bold="True" Font-Names="Arial"  Font-Size="14px" ForeColor="#C31D1D" Text='<%# Bind("price") %>'></asp:Label>

now in my table i have a coloum called available,

if it is empty ("") than a want the price to show
and if it not empty("No Stock" ) that label must show No Stock

please help...
0
Comment
Question by:JCWEBHOST
  • 3
4 Comments
 
LVL 10

Accepted Solution

by:
OnALearningCurve earned 500 total points
ID: 36501068
Hi JCWEBHOST,

Not sure if this will work but it is worth a shot:

<%# IIf(Eval("available").ToString().Equals(""), Bind("price"), "No Stock") %>' />

Hope this helps,

Mark.
0
 

Author Comment

by:JCWEBHOST
ID: 36501103
ok can you show me how this binding will work?

if available is null than the property of the label visiable must be true, else false

please...
0
 
LVL 10

Expert Comment

by:OnALearningCurve
ID: 36501193
I'm not 100% sure because this is a little out of my league but maybe you could wrap the label in a div and use a similar technique to hide or display the div

something like:

<div id="divavailable" style='<%# IIf(Eval("available").ToString().Equals(""), "display:none", "display:list-item") %>' >
      <asp:Label ID="lblavailable" runat="server" Font-Bold="True" Font-Names="Arial"  Font-Size="14px" ForeColor="#C31D1D" Text='<%# IIf(Eval("available").ToString().Equals(""), Bind("price"), "No Stock") %>' />'></asp:Label>
</div>

HTH

Mark.
0
 
LVL 10

Expert Comment

by:OnALearningCurve
ID: 36501598
Thanks for the points,

glad I could help
0

Featured Post

Free Tool: Site Down Detector

Helpful to verify reports of your own downtime, or to double check a downed website you are trying to access.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Problem Hi all,    While many today have fast Internet connection, there are many still who do not, or are connecting through devices with a slower connect, so light web pages and fast load times are still popular.    If your ASP.NET page …
International Data Corporation (IDC) prognosticates that before the current the year gets over disbursing on IT framework products to be sent in cloud environs will be $37.1B.
With Secure Portal Encryption, the recipient is sent a link to their email address directing them to the email laundry delivery page. From there, the recipient will be required to enter a user name and password to enter the page. Once the recipient …
A short tutorial showing how to set up an email signature in Outlook on the Web (previously known as OWA). For free email signatures designs, visit https://www.mail-signatures.com/articles/signature-templates/?sts=6651 If you want to manage em…

856 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question