Solved

Repeater itemtemplate if then statement based on database value

Posted on 2008-06-17
2
1,120 Views
Last Modified: 2012-05-05
Hi,

I'm trying to setup an itemtemplate for a repeater.   What needs to happen is if the database field "inventory" equals 0, then the item should say "(backordered)" otherewise it should display a textbox someone can enter an amount they want to order.  I

 have no idea how to start this since I don't know how to get an if statement to use a database value without erroring out, or how to setup a function to call other database values from inside the repeater control.  I am using C# if that makes a difference.

Any help is appreciated
0
Comment
Question by:fwong1
[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
2 Comments
 
LVL 13

Accepted Solution

by:
sm394 earned 250 total points
ID: 21811953
// IN CS
//========================================================
protected bool Display(object dataItem)
    {

        if ((string)DataBinder.Eval(dataItem, "inventory") == "0" )
            return false;
        else
            return true;

    }
========================================================
IN ASPX
Visible="<%# Display(Container.DataItem) %>"
//=======================================================
assuming you have two controls one label with  text backordered and one text
you can set them visible based on that if condition
0
 

Author Closing Comment

by:fwong1
ID: 31468166
That's genius...
0

Featured Post

Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

Lots of people ask this question on how to extend the “MembershipProvider” to make use of custom authentication like using existing database or make use of some other way of authentication. Many blogs show you how to extend the membership provider c…
Today is the age of broadband.  More and more people are going this route determined to experience the web and it’s multitude of services as quickly and painlessly as possible. Coupled with the move to broadband, people are experiencing the web via …
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 …
Exchange organizations may use the Journaling Agent of the Transport Service to archive messages going through Exchange. However, if the Transport Service is integrated with some email content management application (such as an antispam), the admini…

761 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