最新添加的记录标识
利用sql 表中的标识字段作为键码,该值总是递增的。
在GRIDVIEW的ROWDATABOUND事件中获取改标识字段的值,可以得到最新添加的记录标识
protected void gvsbls_RowDataBound(object sender, GridViewRowEventArgs e)
{
string str1;
int tmpflag = 0;
if (e.Row.RowType == DataControlRowType.DataRow)
{//空记录时不能设置
Button btnHiddenPostButton2 = e.Row.FindControl("btn2") as Button;
if (btnHiddenPostButton2 != null)
{
str1 = btnHiddenPostButton2.ClientID;
e.Row.Attributes[" = String.Format("_javascript:document.getElementById('{0}').click()", btnHiddenPostButton2.ClientID);
// 额外样式定义
e.Row.Attributes[" = "_javascript:this.style.background='yellow'";
e.Row.Attributes[" = "_javascript:this.style.background=''";
e.Row.Attributes["style"] = "cursor:pointer";
e.Row.Attributes["title"] = "单击当前记录可查看批复结果";
tmpflag = Convert.ToInt16(e.Row.Cells[11].Text);
if (tmpflag > maxflag) maxflag = tmpflag;
}
// 若希望将隐藏按钮单独放于一列,则设置此列隐藏,占位符
}