Solved

Conditional format table without codebehind

Posted on 2010-11-15
2
544 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
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

Find Ransomware Secrets With All-Source Analysis

Ransomware has become a major concern for organizations; its prevalence has grown due to past successes achieved by threat actors. While each ransomware variant is different, we’ve seen some common tactics and trends used among the authors of the malware.

Join & Write a Comment

Suggested Solutions

In .NET 2.0, Microsoft introduced the Web Site.  This was the default way to create a web Project in Visual Studio 2005.  In Visual Studio 2008, the Web Application has been restored as the default web Project in Visual Studio/.NET 3.x The Web Si…
A quick way to get a menu to work on our website, is using the Menu control and assign it to a web.sitemap using SiteMapDataSource. Example of web.sitemap file: (CODE) Sample code to add to the page menu: (CODE) Running the application, we wi…
Sending a Secure fax is easy with eFax Corporate (http://www.enterprise.efax.com). First, Just open a new email message.  In the To field, type your recipient's fax number @efaxsend.com. You can even send a secure international fax — just include t…
Get a first impression of how PRTG looks and learn how it works.   This video is a short introduction to PRTG, as an initial overview or as a quick start for new PRTG users.

759 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

22 Experts available now in Live!

Get 1:1 Help Now