Solved

Conditional format table without codebehind

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

Courses: Start Training Online With Pros, Today

Brush up on the basics or master the advanced techniques required to earn essential industry certifications, with Courses. Enroll in a course and start learning today. Training topics range from Android App Dev to the Xen Virtualization Platform.

Question has a verified solution.

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

This article is for Object-Oriented Programming (OOP) beginners. An Interface contains declarations of events, indexers, methods and/or properties. Any class which implements the Interface should provide the concrete implementation for each Inter…
Real-time is more about the business, not the technology. In day-to-day life, to make real-time decisions like buying or investing, business needs the latest information(e.g. Gold Rate/Stock Rate). Unlike traditional days, you need not wait for a fe…
This Micro Tutorial will teach you how to censor certain areas of your screen. The example in this video will show a little boy's face being blurred. This will be demonstrated using Adobe Premiere Pro CS6.
Two types of users will appreciate AOMEI Backupper Pro: 1 - Those with PCIe drives (and haven't found cloning software that works on them). 2 - Those who want a fast clone of their boot drive (no re-boots needed) and it can clone your drive wh…

776 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