Go Premium for a chance to win a PS4. Enter to Win

x
?
Solved

Data Binding

Posted on 2011-09-08
4
Medium Priority
?
276 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 2000 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: SSL Checker

Scans your site and returns information about your SSL implementation and certificate. Helpful for debugging and validating your SSL configuration.

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

Performance in games development is paramount: every microsecond counts to be able to do everything in less than 33ms (aiming at 16ms). C# foreach statement is one of the worst performance killers, and here I explain why.
The article shows the basic steps of integrating an HTML theme template into an ASP.NET MVC project
How to fix incompatible JVM issue while installing Eclipse While installing Eclipse in windows, got one error like above and unable to proceed with the installation. This video describes how to successfully install Eclipse. How to solve incompa…
Please read the paragraph below before following the instructions in the video — there are important caveats in the paragraph that I did not mention in the video. If your PaperPort 12 or PaperPort 14 is failing to start, or crashing, or hanging, …

885 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