Solved

Data Binding

Posted on 2011-09-08
4
267 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
Comment Utility
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
Comment Utility
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
Comment Utility
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
Comment Utility
Thanks for the points,

glad I could help
0

Featured Post

Enabling OSINT in Activity Based Intelligence

Activity based intelligence (ABI) requires access to all available sources of data. Recorded Future allows analysts to observe structured data on the open, deep, and dark web.

Join & Write a Comment

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 …
This article is for Object-Oriented Programming (OOP) beginners. An Interface contains declarations of events, indexers, methods and/or properties. Any class which implements the Interface should provide the concrete implementation for each Inter…
Illustrator's Shape Builder tool will let you combine shapes visually and interactively. This video shows the Mac version, but the tool works the same way in Windows. To follow along with this video, you can draw your own shapes or download the file…
Access reports are powerful and flexible. Learn how to create a query and then a grouped report using the wizard. Modify the report design after the wizard is done to make it look better. There will be another video to explain how to put the final p…

762 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

Need Help in Real-Time?

Connect with top rated Experts

5 Experts available now in Live!

Get 1:1 Help Now