Solved

Repeater itemtemplate if then statement based on database value

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

SharePoint Admin?

Enable Your Employees To Focus On The Core With Intuitive Onscreen Guidance That is With You At The Moment of Need.

Question has a verified solution.

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

Sometimes in DotNetNuke module development you want to swap controls within the same module definition.  In doing this DNN (somewhat annoyingly) swaps the Skin and Container definitions to the default admin selections.  To get around this you need t…
Introduction This article shows how to use the open source plupload control to upload multiple images. The images are resized on the client side before uploading and the upload is done in chunks. Background I had to provide a way for user…
Come and listen to Percona CEO Peter Zaitsev discuss what’s new in Percona open source software, including Percona Server for MySQL (https://www.percona.com/software/mysql-database/percona-server) and MongoDB (https://www.percona.com/software/mongo-…
In this video, viewers will be given step by step instructions on adjusting mouse, pointer and cursor visibility in Microsoft Windows 10. The video seeks to educate those who are struggling with the new Windows 10 Graphical User Interface. Change Cu…

705 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