have a Look at the Code Snippet
C# Code..
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
}
}
}
}
0 comments:
Respects for your's Questions & Opinions