Want to win a PS4? Go Premium and enter to win our High-Tech Treats giveaway. Enter to Win

x
?
Solved

Repeater itemtemplate if then statement based on database value

Posted on 2008-06-17
2
Medium Priority
?
1,136 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 1000 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

VIDEO: THE CONCERTO CLOUD FOR HEALTHCARE

Modern healthcare requires a modern cloud. View this brief video to understand how the Concerto Cloud for Healthcare can help your organization.

Question has a verified solution.

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

One of the pain points with developing AJAX, JavaScript, JQuery, and other client-side behaviors is that JavaScript doesn’t allow for cross domain request for pulling content. For example, JavaScript code on www.johnchapman.name could not pull conte…
It was really hard time for me to get the understanding of Delegates in C#. I went through many websites and articles but I found them very clumsy. After going through those sites, I noted down the points in a easy way so here I am sharing that unde…
In this video you will find out how to export Office 365 mailboxes using the built in eDiscovery tool. Bear in mind that although this method might be useful in some cases, using PST files as Office 365 backup is troublesome in a long run (more on t…
Want to learn how to record your desktop screen without having to use an outside camera. Click on this video and learn how to use the cool google extension called "Screencastify"! Step 1: Open a new google tab Step 2: Go to the left hand upper corn…

598 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