Solved

Conditional format table without codebehind

Posted on 2010-11-15
2
570 Views
Last Modified: 2012-05-10
I inherited a project with a giant table in an aspx page that has a TON of inline code. Now I need to conditionally style a row based on the value of a textbox in the table. Unfortunately, I can't add a "runat=Server" tag to the table row because of all the embedded <% %> tags. I just need to apply the style to this row. I know all this embedded stuff needs to move to the code behind. I didn't write this - I just need to get this one small thing fixed.

        <ajax:Accordion ID="Accordion1" runat="server" FadeTransitions="False"  
            SelectedIndex="0" HeaderCssClass="accordionHeader" ContentCssClass="accordionContent">
                <HeaderTemplate>
                    <div style="height:20px;">&nbsp;</div>
                    <table class="cart" >
                        <tbody>
                        <ItemTemplate>      
                                <tr class="row I need to style  " >                                   
                                <%if (Isvalid) { %>.... tons more tags like this in the td sections.

Any advice?
0
Comment
Question by:BrogansMom
[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 3

Accepted Solution

by:
xeonol earned 500 total points
ID: 34142191
You can do a switch in the tr class:
   <ItemTemplate>       
       <tr class="<? switch(Eval("datafield you based for style"){case ... ...}?>" >                                 
            <%if (Isvalid) { %>.... tons more tags like this in the td sections. 
            ...

Open in new window

 
0
 

Author Comment

by:BrogansMom
ID: 34142316
After walking away for a bit, I tried putting an asp panel around it and then setting visibility of the panel in the code behind. Working perfectly now. Accepting switch because that would have worked as well.
0

Featured Post

Free Tool: Postgres Monitoring System

A PHP and Perl based system to collect and display usage statistics from PostgreSQL databases.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

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 …
Entity Framework is a powerful tool to help you interact with the DataBase but still doesn't help much when we have a Stored Procedure that returns more than one resultset. The solution takes some of out-of-the-box thinking; read on!
How to Install VMware Tools in Red Hat Enterprise Linux 6.4 (RHEL 6.4) Step-by-Step Tutorial
Are you ready to implement Active Directory best practices without reading 300+ pages? You're in luck. In this webinar hosted by Skyport Systems, you gain insight into Microsoft's latest comprehensive guide, with tips on the best and easiest way…

740 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