日期:2014-05-18 浏览次数:20557 次
protected void gridview1_RowDataBound1(object sender, GridViewRowEventArgs e) { if (e.Row.RowType == DataControlRowType.DataRow) { //鼠标经过时,行背景色变 e.Row.Attributes.Add("onmouseover", "this.style.backgroundColor='#C2FF68'"); //鼠标移出时,行背景色变 e.Row.Attributes.Add("onmouseout", "this.style.backgroundColor='#FFFFFF'"); e.Row.Attributes.Add("style", "cursor: hand;");//将光标设为手形 //为gridview添加行链接 e.Row.Attributes.Add("onclick", "window.location.href='Reply.aspx?ID=" + this.gridview1.DataKeys[e.Row.RowIndex].Value + "'"); //删除时弹出确认对话框 if (e.Row.RowState == DataControlRowState.Normal || e.Row.RowState == DataControlRowState.Alternate) { ((LinkButton)e.Row.Cells[7].Controls[0]).Attributes.Add("onclick", "javascript:return confirm('你确认要删除编号是:\"" + e.Row.Cells[1].Text + "\"的信息吗?')"); } } }
//为gridview添加行链接 e.Row.Attributes.Add("onclick", "window.location.href='Reply.aspx?ID=" + this.gridview1.DataKeys[e.Row.RowIndex].Value + "'"); Row_Command事件代码如下: protected void gvRoom_RowCommand(object sender, GridViewCommandEventArgs e) { if (e.CommandArgument=="show") { Page.Server.Transfer("Reply.aspx?ID="+你要传递的参数); } }