Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations derfloh on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

ItemTemplate Conditional CodeBehind

Status
Not open for further replies.

tqeonline

MIS
Oct 5, 2009
304
US
I have a website that creates labels through an item template.

Here is the code in the page
Code:
<itemtemplate>
<asp:Label runat="server" ID="lblDefect" Text='<%# Eval(&quot;Application&quot;) +&quot; &quot;+ Eval(&quot;Duration&quot;)%>' ToolTip='<%# &quot;Defect ID#&quot; &amp; Eval(&quot;Defect&quot;) &amp; &quot; - &quot; &amp; Eval(&quot;DetectedInCycle&quot;)%>'></asp:Label>
</itemtemplate>

The sqldatasource also has an "Environment" and what I want to be able to do is code a conditional statement like this:

Code:
If "Environment" = "QA 02" then 
     label.backcolor = vbRed
elseif "Environment" = "QA 03" then
     label.backcolor = vbBlue
else...
end if

So i need to be able to evaluate the "Environment" for any given label within the itemtemplate and shade the backcolor for a given criteria.

How can I do this in the code behind?
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top