Solved

Repeater itemtemplate if then statement based on database value

Posted on 2008-06-17
2
1,084 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
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

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

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…
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 …
Polish reports in Access so they look terrific. Take yourself to another level. Equations, Back Color, Alternate Back Color. Write easy VBA Code. Tighten space to use less pages. Launch report from a menu, considering criteria only when it is filled…
This video shows how to remove a single email address from the Outlook 2010 Auto Suggestion memory. NOTE: For Outlook 2016 and 2013 perform the exact same steps. Open a new email: Click the New email button in Outlook. Start typing the address: …

707 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

13 Experts available now in Live!

Get 1:1 Help Now