Introduction:
Here
I will explain how to change gridview
column, row back color dynamically based on particular condition in asp.net
using c#, vb.net.
Description:
In previous articles I explained Display Gridview Columns as Rows, SQL Server Convert Rows to columns, Set Gridview column width dynamically, jQuery Menu with Bounce Effect, Different type of constraints in SQL Server and many articles relating to jQuery, asp.net, CSS. Now I will explain how to change gridview column background color dynamically based on particular condition in asp.net using c#, vb.net.
In previous articles I explained Display Gridview Columns as Rows, SQL Server Convert Rows to columns, Set Gridview column width dynamically, jQuery Menu with Bounce Effect, Different type of constraints in SQL Server and many articles relating to jQuery, asp.net, CSS. Now I will explain how to change gridview column background color dynamically based on particular condition in asp.net using c#, vb.net.
To change gridview column background color dynamically we
need to write the code like as shown below
C# Code
|
VB Code
|
If you want to know more ways to change column width
style check this article
If you want to see it in complete example check below
code
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<title>Convert
Gridview Columns as Rows in Asp.net</title>
<style type="text/css">
body
{
font-family:Calibri;
}
.gridcss
{
background:#df5015;
font-weight:bold;
color:White;
}
</style>
</head>
<body>
<form id="form1"
runat="server">
<asp:GridView ID="gvdata" runat="server" OnRowDataBound=gvdata_RowDataBound>
</asp:GridView>
</form>
</body>
</html>
|
Now
in code behind add the following namespace references
C#
Code
|
After
that write the following code in code behind
|
VB.NET
Code
|
Demo
If you enjoyed this post, please support the blog below. It's FREE! Get the latest Asp.net, C#.net, VB.NET, jQuery, Plugins & Code Snippets for FREE by subscribing to our Facebook, Twitter, RSS feed, or by email. |
|||
|
|||
6 comments :
I want Code for edit profile page..in c#
I learnt something from your programs..
thanq.....
hey please add code for dynamically value add in datagridview
hi can we do this using stored procedure???
In gridview i want to add dropdownlist or comboox with predefined colors(blue,green,orange etc).If i select color from dropdownlist or comboox it should update that color in db table.How we can do this??
Thank you sir.............this is very good & easy way..........................
Note: Only a member of this blog may post a comment.