Changing style of GridView Row in code-behind on a CSS-Friendly Gridview

Hey folks, here's the problem:

I have a gridview that displays messages, and I want the unread messages to be displayed as bold.  Simple, right?  One problem: while you can set the CssClass in the code-behind to accomplish this, you can't set the CssSelectorClass.

        Protected Sub GridView1_RowDataBound(ByVal sender As Object, ByVal e As System.Web.UI.WebControls.GridViewRowEventArgs) Handles GridView1.RowDataBound
            Dim msg As Message = CType(e.Row.DataItem, Message)
            If e.Row.RowType = DataControlRowType.DataRow Then
                If Not msg.ReadDate.HasValue Then
                    e.Row.CssClass = " .Unread"
                End If
            End If
        End Sub

 Any ideas how to go about creating a work-around for this?

Note: I've tried disabling the adapter and it functions like that, but I can't get the rest of the GridView styled.


Jordan Burke
President - Epik Technologies, LLC
0
Antilles128
4/9/2008 3:44:09 AM
asp.net.css-control-adapters 905 articles. 0 followers. Follow

0 Replies
650 Views

Similar Articles

[PageSpeed] 24

Reply:

Similar Artilces:

css toolkit adapters- apply css style to gridview row in code (c#)
I was trying to change the colour of a row in a gridview depending on data contained within using MyGridView_RowDataBound, and found a nice little change to the css adapters to allow this. Thought I should share. Add the following code before "return className.Trim();" in the function GetRowClass(GridView gridView, GridViewRow row) in GridViewAdapter.cs. (I keep this in ~/App-Code/Adapters/)if ((row.RowState == DataControlRowState.Normal)) { className += row.CssClass; } In your gridview css file add the colors you need EG: .MyGridViewCSSselectorCl...

CSS Friendly Control Adapters not support dynamically created rows in GridView?
I have a dynamically created row in GridView control. But it will not appear when I use CSS Friendly Control Adapter. I have to set adapterenabled=false to make it work. But I will loss all the table style in this way. Any better ideas to solve this problem? This is the code behind to add a new row.protected void GridView3_RowDataBound(object sender, GridViewRowEventArgs e) {GridViewRow insertedRow = new GridViewRow(GridView3.Rows.Count, GridView3.Rows.Count, DataControlRowType.DataRow, DataControlRowState.Normal); TableCell cell = new TableCell();cell.Text = " hello"; cel...

CSS Friendly Control Adapters + GridView + Update Panel = Problem
Hi everyone,I'm using a gridview control that's bound to an object data source.  I have a couple of controls to filter the data in the gridview, and I'm able to sort and page through the data. Placing it in an UpdatePanel gives me partial page rendering and the whole page doesn't refresh - Great.  Expected behaviour and it all works very well. However, introduce a Control Adapter into the mix (http://www.asp.net/cssadapters/) and Update Panel doesn't work at all - with the whole page refreshing. If anybody can offer any help, I'd be very grateful.  I want both A...

CSS Control Adapter for Gridview
I am tryin to style a gridview.My site is using CSS Friendly control adapter. I am new to this. Can u guys pls help me make the gridview look better. Every time i add a div tag,i get an error that div is not a property of the gridview.If i put it to envelope the gridview, nothin happens!! Thanks.  If you left the (ID) of the GridView as GridView1 then you should be able to find <div class="AspNet-GridView" id="GridView1"> in the source when you run the page.   You can use the class to style the GridView.  You should also be able to find ot...

Add new controls to a gridview row; when editing that row using the edit row feature in the gridview control.
Hi all  I have a questions that looks hard / complex to me, and i know you can help me in this. Q {  I have row in a Gridview and i have an edit option to it. I press the edit button, to edit the values in that row and update data all the way back to the database. Now when i press the edit button, i want a drop down list to be displayed that contain values for a particular field in my grid view. (for now only plain text boxes appear.) } I hope you understand my question, all i need to do is replace the text box controls with a dropdown list when i am editing a row in ...

Gridview pager with Css friendly adapter
I tried to add a PageTemplate in the GridView but nothing can display. <PagerTemplate> <!--my own pager--></PagerTemplate> It will works well when I use AdapterEnabled=false. So, It looks like a Css friendly adapter bug.  I found this thread( ttp://forums.asp.net/p/1077943/1726070.aspx#1726070) after search around. But suggestions on it still can't fix my problem. Any ideas? Thanks. I added my page navagation bar into the footer of  the table columns. It is long so I have to seprate them and put into 2 cells. Not very handy but works....

CSS Friendly Adapters and Gridview autoformat
  Hi I am using CSS Friendly Adapters. I have included following in my project: 1.CSSFriendlyAdapters.browser in App_Browsers folder 2. CSSFriendly.dll in Bin folder I have gridview for which I have selected AutoFormat scheme as 'Classic'  But when I run application  AutoFormat scheme 'Classic' is not applied to gridview.          This is working the way as designed. Note that these are sample adapters are designed to only use content attributes and ignore the style attributes of a control.  As with the ...

What is the advantage of the CSS control adapter for the gridview?
 The Grid View has built in styling capabilities with the "HeaderStyle-CssClass" and the "ItemStyle-CssClass" attributes.  Why sould someone want to use the CSS Friendly Control Adapter for this if it has this built in capability?  The html that it produces via the adapter doesn't seem that much better than the html that it produces normally.  Is the only reason to use the adapter on the Grid View so that the output can be manually changed?  For instance,  the table that is put out by the Grid View can canged into <divs>.  ...

Gridview
Hello All, I've got a gridview with a template field and I'm able to display all of the content in that column ... I'm using the For and Next Statement to scroll thru the rows ... how do I just display the column data on the first row?For s = 0 To GridView2.Rows.Count - 1 Dim row As GridViewRow = GridView2.Rows(s) Dim UserID As String = CType(row.FindControl("Label1"), Label).Text Response.Write(UserID) Next A couple of choices, one you can create a stored procedure to just return one row or you can add a condition on your loop by checking to see if its the...

Applying styles to GridView control in external CSS
Alright, I've looked everywhere but I still can't seem to find a simple explanation of how to apply styles to a GridView control. I just need to know the attributes of a GridView control that can be customized. For example, I already figured out that I can customize the "caption" attribute: my GridView control has 'CssClass = "thisClass"' and my stylesheet has '.thisClass caption { color:Blue: }'I need to get the names of the attributes of the GridView control such that I can eliminate the border and apply other formatting styles. Thanks a bunch in advance. Can anybody offer some insight?...

Add a CSS class from Style.css to a simple html table in code behind
I have a CSS class that sits in Style.css.  In the aspx page there is a simple html table.  I added runat="server" to the table and gave it an ID.  If certain conditions are met in the data pulled from the database, I need to add a CSS class to this table.  My problem is that there doesn't seem to be a CSSClass property to this table.  I can add style code directly to the table but why do that if the CSS class already exists? So, How do I dynamically add a call to the class from my code behind?HTML in .aspx file: <table border="0" cellspa...

Does the CSS friendly GridView have problems showing selected rows?
It seems it doesn't render the selected rows.I tried using: <SelectedRowStyle BackColor="yellow" />both in the skin file and in the aspx file, and this is after trying to change the CSS marked ".MyGridView .AspNet-GridView table tbody tr.AspNet-GridView-Selected td" Crawling up the walls, started digging into the code, found out that:This doesn't occurr for all rows, just for the alternate ones. Normal items are rendered properly.The reason is simple: the adapter doesn't render a AspNet-GridView-Selected Class for the alternate ones, in fact, it doesn...

Freezing the column header row of a GridView control using CSS
I am struggling getting my Gridview in ASP.NET 2.0 Visual Studio 2005 to freeze the column header row and provide for scrolling of the remaining data rows. My specific problems right now are: (IE7) column headers freeze as intended and do not scroll  BUT scroll bar is not initially visible to user (requires scrolling with mouse wheel before scroll bars are exposed in gridview) (Firefox 2.0.10) column header row just scrolls out of sight like any other row  Here is part of my default.css in my default App_Theme folder: /* So the overflow scrolls */ div.coveragesContainer ...

Simple? How do I change values in the gridview from code behind, then update the row?
I want to programmatically change gridview field values, then run Gridview.Rowupdate(x)... I don't want the user to have to click edit etc. this has to be easy, how is it done? Thanks!   Consider a gridview: ID  |  Name  |  Social 1      Dude     122 2      Dood      145 3     Dewd      123   I want to Change "145" text/value to 555 - then update the row manually...   in page_load event, write ...

Web resources about - Changing style of GridView Row in code-behind on a CSS-Friendly Gridview - asp.net.css-control-adapters

Review: Adobe Dreamweaver CC makes CSS more visual, less coder-friendly
... it distances design from code more than previous versions did. No more square boxes Dreamweaver CC’s most obvious enhancement is its new CSS ...

Resources last updated: 12/12/2015 3:26:05 AM