我想在网格视图上突出显示最后插入的记录。在我的网格视图中,我有一个主键列。新插入的行按照此主键的升序排列。现在我想突出显示最后插入的行。从我这样写的搜索中,但它显示网格视图的最后一行突出显示。,而不是新插入的行。请帮忙。我的代码在这里,
int lastRowIndex = 0;
if(!IspostBack)
{
string select_string="SELECT student_name,student_id,student_nric,student_group FROM student_details WHERE student_group='"+groups[0].ToString().Trim()+"' ";
for(int i=1;i<groups.Count;i++)
{
select_string+= " or student_group='"+groups[i].ToString().Trim()+"'";
}
if(Session["STUDENT_ID"]!=null)
{
for(int i=0;i<student_id_list.Count;i++)
{
select_string+= " or student_id='"+student_id_list[i].ToString().Trim()+"'";
}
}
SqlDataAdapter adapter = new SqlDataAdapter(select_string, con);
adapter.Fill(ds);
GridView2.DataSource = ds;
GridView2.DataBind();
con.Close();
foreach (GridViewRow grv in GridView2.Rows)
{
if (grv.RowType == DataControlRowType.DataRow)
{
if (grv.RowIndex > lastRowIndex)
{
lastRowIndex = grv.RowIndex;
}
}
}
lastRowIndex = GridView2.Rows.Count - 1;
GridView2.Rows[lastRowIndex].BackColor = System.Drawing.Color.LightGoldenrodYellow;
}
}
}