Solved

Data Binding

Posted on 2011-09-08
4
269 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

Courses: Start Training Online With Pros, Today

Brush up on the basics or master the advanced techniques required to earn essential industry certifications, with Courses. Enroll in a course and start learning today. Training topics range from Android App Dev to the Xen Virtualization Platform.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
how to check to see if datatable has headers or not 2 25
MediaHelp 4 21
application restarter  - for an exe that hangs 9 24
C# Gridview 1 28
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 …
Calculating holidays and working days is a function that is often needed yet it is not one found within the Framework. This article presents one approach to building a working-day calculator for use in .NET.
Sending a Secure fax is easy with eFax Corporate (http://www.enterprise.efax.com). First, just open a new email message. In the To field, type your recipient's fax number @efaxsend.com. You can even send a secure international fax — just include t…
In a recent question (https://www.experts-exchange.com/questions/28997919/Pagination-in-Adobe-Acrobat.html) here at Experts Exchange, a member asked how to add page numbers to a PDF file using Adobe Acrobat XI Pro. This short video Micro Tutorial sh…

813 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

10 Experts available now in Live!

Get 1:1 Help Now