Grid View Footer background Color based on either RowStyle background Color or or AlternatingRowStyle background Color

Hi Friends,
            As of my requirement,I have a grid view .Now the background color of the Footer of Grid view ,will have to be dynamic,i mean it will depend upon Row Style background color and  AlternatingRowStyle background  Color i.e,
if the row above footer have row style ,then footer will have alternative row style background color and if the row above footer have alternative row style ,then footer will have row style background color.

How can it be done.

Regards,
Ritesh
1
mail2rit
3/24/2009 11:45:35 AM
asp.net.presentation-controls 72751 articles. 3 followers. Follow

2 Replies
2316 Views

Similar Articles

[PageSpeed] 49
Get it on Google Play
Get it on Apple App Store

This VB code in your GridView RowDataBound event may work for you:

If e.Row.RowType = DataControlRowType.DataRow Then
  If
e.Row.RowState = DataControlRowState.Normal Then
    GridView.FooterStyle.BackColor = GridView.RowStyle.BackColor
  ElseIf e.Row.RowState = DataControlRowState.Alternate Then
    GridView.FooterStyle.BackColor = GridView.AlternatingRowStyle.BackColor
  End If
End If

 

1
paindaasp
3/24/2009 1:31:55 PM

Hi mail2rit,

You can handle it in DataBound event of GridView:

protected void GridView1_DataBound(object sender, EventArgs e)
    {
        if (GridView1.Rows.Count % 2 == 1)    //check the count of rows to decide the footer color should be which one
            GridView1.FooterRow.BackColor = System.Drawing.Color.Red;   //set the color to the one in AlternatingRow
        else
            GridView1.FooterRow.BackColor = System.Drawing.Color.Blue;   //set the color to the one in DataRow
    }

Thanks,


Qin Dian Tang
Microsoft Online Community Support

Please remember to mark the replies as answers if they help and unmark them if they provide no help.
1
Qin
3/27/2009 7:36:40 AM
Reply:

Similar Artilces:

Background color rending bug? Content page showing background color?!
Hi all,  I've created a very basic site and am starting to write the CSS.  After adding a masterpage as soon as I add the contentplaceholder my background in the master page and content page are changing to the color of the td row in the CSS? If I run this page without a masterpage, the CSS works fine. Here is the content page: <asp:Content ID="ContentForum" ContentPlaceHolderID="cphMain" runat="Server"> <form id="form1" runat="server"> <div runat="server" id="whatever"> <table wi...

Why some some server text boxes have yellow background color but some white background color?
Why some some server text boxes have yellow background color but some white background color? Thanks in advance!...

cant view background images and background colors
Name: Drew Email: fiercethoughts_at_yahoo.com Product: Firefox Summary: cant view background images and background colors Comments: i cannt view BG images and colors using firefox 2.0 i would really love it if yall hit me back and tell me how to fix this problem. thanks Browser Details: Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.8.1) Gecko/20061010 Firefox/2.0 ...

Why would my text box background color be different for different text boxes without setting the background color
I have a form that has about a half dozen seperate text boxes. I have not set anything on these text boxes other than width sizes.  For some reason however when I build the page shows that some of the text boxes has a yellow background and some have a white background.  Any ideas what the problem could be.  You can see in the code below that no background color is set.  BTW this is VS2008..I do impose a theme on the page but the theme sets a back color of white...so in theory there shoudnt be any yellow backcoloered text boxes.   Theme code<asp:TextBox runa...

How to make template field control color same as row background color
This is really a two part thing:  1.)  I want to make a linkbutton control in a templatefield the same color as the row color. I have alternating row colors, so I can't just hard code it. 2.) I want to make the link button change colors when the mouse goes over the ROW. Then go back to row color onmouseout.  So basically, the link will be invisible until the row is moused over.  Thanks! Here are a couple of examples.  In GridView1, the HyperLink color is set to match the background color.  Note the RowStyle and AlternatingRowStyle do not override ...

set text color or background color in a gridview based on values
Is there a way to set font-clor or background-color of cells in a gridview? For example:  If the cell value is 0 : set font color/background-color to red, if value =10 set font-color/background-color to green?  Thanks                                                 A sample by using RowDataBound event. Add  OnRowDataBound="gv_RowDataBou...

Dropdownlist with a color from the DB in background-color
Please help!! I need to put the "cd_cor" as the background-color style. For each item we have one color. Thank You for Help!The code is below:Public Sub BindCategoria()Dim rc As Boolean = FalseDim adoDS As ADODataSet = New ADODataSet(EducarLib.Educar.ConnectionString)adoDS.TableName = "Categorias"adoDS.SqlCmd = "Select cd_cor, id_categoria, nm_categoria From Categoria Order by nm_categoria"rc = adoDS.ExecuteQuery() If rc Then dropCategoria.DataTextField = "nm_categoria"dropCategoria.DataValueField = "id_categoria"dropCategoria.DataSource =...

Setting background color to a generic color
Our rich edit fields are set to clWindow when “editing/active” and when “saved/inactive” they are set to clSilver. Highlighting is only allowed when editing. However if you highlight a section of text and then unhighlight it the text background is saved and when set to inactive the section that was unhighlighted is clWindow/white instead of clSilver. This is the code I got from Peter Below which works great but I am looking for a generic back ground color that does not show up when the color is changed. if LSetHighlite then CF.crBackColor := NHighliteColor else CF.crBackColor := ColorT...

turning off color and background-color bug ?
Hi, I have a question about a Firefox behaviour, for my it's an accessibility bug but maybe i am wrong. When the user turn off the color in his preference, all the element with absolute positioning and a background color become transparent instead of inheriting the root element background color or the default system background color. A practical example can be the dropdown menu, when i turn off the color, the background of the menu become transparent and his content become unreadable because it overlay the page content (for example look at the quick contact feature in gmail...

superreview requested: [Bug 292191] If using background-image in an element, we should reverse the result of reverse selection algorithm when the element's foreground color and background color is sim
Masayuki Nakano (Mozilla Japan) <masayuki@d-toybox.com> has asked Boris Zbarsky <bzbarsky@mit.edu> for superreview: Bug 292191: If using background-image in an element, we should reverse the result of reverse selection algorithm when the element's foreground color and background color is similar https://bugzilla.mozilla.org/show_bug.cgi?id=292191 Attachment 192919: Patch rv1.0 https://bugzilla.mozilla.org/attachment.cgi?id=192919&action=edit ...

superreview cancelled: [Bug 292191] If using background-image in an element, we should reverse the result of reverse selection algorithm when the element's foreground color and background color is sim
Masayuki Nakano (Mozilla Japan) <masayuki@d-toybox.com> has cancelled Masayuki Nakano (Mozilla Japan) <masayuki@d-toybox.com>'s request for superreview: Bug 292191: If using background-image in an element, we should reverse the result of reverse selection algorithm when the element's foreground color and background color is similar https://bugzilla.mozilla.org/show_bug.cgi?id=292191 Attachment 192919: Patch rv1.0 https://bugzilla.mozilla.org/attachment.cgi?id=192919&action=edit ------- Additional Comments from Masayuki Nakano (Mozilla Japan) <masayuki@d-...

Bug 549558
When background and text colors are set via the Composition tab of the Options dialog, Thunderbird places those colors in the body tag of a message, and a web mail recipient sees black font on white background regardless of sender=92s intention. This is because web mail sites like GMail ignore or strip off the body tag to prevent the entire interface from taking on the colors of the message. The sender is unaware of the problem unless the message is replied to. When the colors are set via the color icon of the new message window prior to clicking the karat into the message body pane, ...

Use Hex Color Value as Background color in Gridview
Hello All,  What I'm doing is pulling a dataset which includes a background color field.  What I want to do is set the background color of that column to the value of the HEX value returned for that record.  What I'm getting is a can not convert to object error. I am using a boundfield control for the column I want to color.   Thanks in advanced.  D/New .NET Programmer I don't know exactly how the HEX color value is saved in your DB. Sth like this should work:int winColor = 0x009536DD; // HEX A, R, G, B GridView1.Rows[e.RowIndex].Cells[0].Bac...

How to set the background fill color and font color for the range?
Hi all, I had set the range as follow: range = worksheet1.get_Range("A137", "AG2"); range.Borders[XlBordersIndex.xlEdgeTop].LineStyle = Excel.XlLineStyle.xlContinuous; May I know how to set the background color and font color for this range? Please help. Thanks ...

Web resources about - Grid View Footer background Color based on either RowStyle background Color or or AlternatingRowStyle background Color - asp.net.presentation-controls

Resources last updated: 1/14/2016 5:03:01 AM