Solved

Data Binding

Posted on 2011-09-08
4
273 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 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: 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

ASP.Net to Oracle Connectivity Recently I had to develop an ASP.NET application connecting to an Oracle database.As I am doing it first time ,I had to solve several problems. This article will help to such developers  to develop an ASP.NET client…
I was asked about the differences between classic ASP and ASP.NET, so let me put them down here, for reference: Let's make the introductions... Classic ASP was launched by Microsoft in 1998 and dynamically generate web pages upon user interact…
In this video, viewers are given an introduction to using the Windows 10 Snipping Tool, how to quickly locate it when it's needed and also how make it always available with a single click of a mouse button, by pinning it to the Desktop Task Bar. Int…
Monitoring a network: why having a policy is the best policy? Michael Kulchisky, MCSE, MCSA, MCP, VTSP, VSP, CCSP outlines the enormous benefits of having a policy-based approach when monitoring medium and large networks. Software utilized in this v…

615 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