Home
|
Tutorial
|
Articles
|
Forum
|
Interview Question
|
Code Snippets
|
News
|
Fun Zone
|
Poll
|
Web Links
|
Certification
|
Search
Welcome :
Guest
Sign In
Register
Win Surprise Gifts!!!
Congratulations!!!
Top 5 Contributors of the Month
satyapriyanayak
Narayanan
Jean Paul
JQuery Developer
Karthikeyan Anbarasan
Home
>>
Forum
>>
ASP.Net
>>
Post New Question
Subscribe to Forum
change row color in GridView
Posted By:
priya
Posted Date:
February 17, 2009
Points:
2
Category :
ASP.Net
How to change the row color in GridView depending upon the value of the column one value.
ex.
if the first column cell value is less than 10 then the row color will be red.
How to do that in asp.net.I am using C# as code behind.
Responses
Author:
Akhil Raj
Company URL:
Posted Date: February 18, 2009 Points: 5
hi friend,
Please try rowbinding event of the gridview
Author:
Athira Sreejith
Company URL:
http://mgu.ac.in/
Posted Date: February 22, 2009 Points: 5
Hi..
Refer this code:
protected void gvTourProgram_RowDataBound(object sender, GridViewRowEventArgs e)
{
if (e.Row.RowType == DataControlRowType.DataRow)
{
GridViewRow gvRow = e.Row;
Label mylblObjective = (Label)e.Row.FindControl("lblObjective");
ImageButton mybtnDelete = (ImageButton)e.Row.FindControl("btnDelete");
CheckBox mychkboxApproval = (CheckBox)e.Row.FindControl("chkApproval");
if (mychkboxApproval.Checked)
{
// mybtnDelete.Enabled = false;
mybtnDelete.Visible = false;
}
else
{
// mybtnDelete.Enabled = true;
mybtnDelete.Visible = true;
}
string strObjective = mylblObjective.Text;
if (strObjective.ToUpper() == "SUNDAY")
{
for (int i = 3; i < gvTourProgram.Columns.Count; i++)
{
if (i != 5)
{
gvRow.Cells[i].Text = string.Empty;
}
else
{
gvRow.Cells[i].ForeColor = System.Drawing.Color.Red;
gvRow.Cells[i].Font.Bold = true;
gvRow.Cells[i].Font.Size = 10;
gvRow.Cells[i].Text = "SUNDAY";
}
}
}
if (strObjective.ToUpper() == "HOLIDAY")
{
for (int i = 3; i < gvTourProgram.Columns.Count; i++)
{
if (i != 5)
{
gvRow.Cells[i].Text = string.Empty;
}
else
{
gvRow.Cells[i].ForeColor = System.Drawing.Color.Green;
gvRow.Cells[i].Font.Bold = true;
gvRow.Cells[i].Font.Size = 10;
gvRow.Cells[i].Text = "HOLIDAY";
}
}
}
}
}
Post Reply
You must
Sign In
To post reply
Related Questions Related Questions
change background color of cell in Gridview programatically
Change GridView row color based on condition
Change the background color of Gridview cell programmatically
Gridview Conditional Color Change
how to change the bg color of null column in gridview?
Latest Forum Questions From The Same Category
How to: Concatenate Multiple Strings
how to upload default image into database when no image file is selected from fileupload control in
code not working
excel upload problem into datatset
how to add images to databse and bind in girdview
Find more Forum Questions on C#, ASP.Net, Vb.Net, SQL Server and more
Here
Quick Links For Forum Categories:
ASP.Net
Windows Application
.NET Framework
C#
VB.Net
ADO.Net
Sql Server
SharePoint
OOPs
Silverlight
IIS
JQuery
JavaScript/VBScript
Biztalk
WPF
Patten/Practices
WCF
Others
www.DotNetSpark.com
UnAnswered
All
Hall of Fame
Twitter
Terms of Service
Privacy Policy
Contact Us
Archives
Tell A Friend