protected void gv1_RowDataBound(object sender, GridViewRowEventArgs e) { //首先判断是否是数据行 if (e.Row.RowType == DataControlRowType.DataRow) { //如果是绑定数据行 增加删除按钮 弹出消息,先引用LTP LinkButton linkbtnEdit = (LinkButton)e.Row.FindControl("lnkbtnEdit"); linkbtnEdit.CommandArgument = e.Row.RowIndex.ToString(); LinkButton linkbtnDel = (LinkButton)e.Row.FindControl("lnkbtnDel"); linkbtnDel.Attributes.Add("onclick", "return confirm(\"你确认要删除吗\")"); linkbtnDel.CommandArgument = e.Row.RowIndex.ToString(); // /*当鼠标停留时更改背景色 //第二种方法 配合前端java函数 e.Row.Attributes.Add("onmouseover", "if(this!=oldrow){currentcolor=this.style.backgroundColor;this.style.backgroundColor='Lavender',this.style.fontWeight='';}"); e.Row.Attributes.Add("onmouseout", "if(this!=oldrow){this.style.backgroundColor=currentcolor;this.style.fontWeight='';}"); string curInteid = gv1.DataKeys[e.Row.RowIndex].Value.ToString(); e.Row.Attributes.Add("onclick", e.Row.ClientID.ToString() + ".checked=true;selectx(this,'"+curInteid+"')"); } }
数据绑定 添加操作的按钮
填写意见:
//同意之确认 function btnApprove_Click() { var k =$("#fldOpinion").val(); if(k=="" || k==null || typeof(k)=="undefined") { if(confirm("请填写意见!")) { document.all("fldOpinion").focus(); $("#fldOpinion").css("background-color","#e5eecc"); return false; } } return true; }