Subscribe
TechTasks.net

The Blog is Moved to www.TechTasks.net

Highlight GridView rows when condition is true

Posted by Rajesh Kumar Chekuri on







using System;

using System.Data;

using System.Configuration;

using System.Web;

using System.Web.Security;

using System.Web.UI;

using System.Web.UI.WebControls;

using System.Web.UI.WebControls.WebParts;

using System.Web.UI.HtmlControls;

using System.Data.SqlClient;

using System.Drawing;

public partial class _Default : System.Web.UI.Page

{

SqlConnection con; DataSet ds; SqlDataAdapter da;

protected void Page_Load(object sender, EventArgs e)

{

con = new SqlConnection("Data Source=TECH-DA98E1DFBA\\SQLEXPRESS;Initial Catalog=tempdb;Integrated Security=True");

con.Open();

da = new SqlDataAdapter("select * from emp", con);

ds = new DataSet();

da.Fill(ds, "emp");

GridView1.DataSource = ds;

GridView1.DataBind();

}

protected void GridView1_RowCreated(object sender, GridViewRowEventArgs e)

{

if (e.Row.DataItem != null)

{

DataRowView drv = (DataRowView)e.Row.DataItem;

int sal = int.Parse(drv["sal"].ToString());

if (sal >= 10000)

e.Row.BackColor = Color.LightBlue ;

//Display gridveiw row in diff color whose sal is greaterthan 10,000

}

}

}

}

Bookmark and Share
Highlight GridView rows when condition is trueSocialTwist Tell-a-Friend

2 comments:

Anonymous said...

It was extremely interesting for me to read that post. Thanx for it. I like such topics and anything that is connected to them. I definitely want to read more on that blog soon.

Anonymous said...

Don't stop posting such stories. I like to read articles like that. Just add more pics :)

Subscribe to: Post Comments (Atom)
Thanks For Visiting