日期:2014-05-17 浏览次数:20422 次
protected void Gv_RowCreated(object sender, GridViewRowEventArgs e) { if (e.Row.RowType == DataControlRowType.DataRow) { LinkButton lbl = (LinkButton)e.Row.FindControl("yourcontrolid"); lbl.Attributes.Remove("onclick"); lbl.Attributes.Add("onclick", "return confirm('确认删除?');"); } }
------解决方案--------------------
((LinkButton)e.Row.Cells[0].Controls[0]).Attributes.Add("onclick", "if(!confirm('确认删除?')){return false;}");
------解决方案--------------------
protected void GridView1_RowDataBound(object sender, GridViewRowEventArgs e) { GridViewRow gvRow = e.Row; LinkButton lbtnClick = gvRow.FindControl("按钮名称"); lbtnClick.OnClientClick = "return confirm('确认删除?')"; }
------解决方案--------------------
LinkButton lbtnClick = gvRow.FindControl("按钮名称") as LinkButton;
------解决方案--------------------
这个是没有问题的!你可以试试
protected void GridView1_RowDataBound(object sender, GridViewRowEventArgs e) { //如果是绑定数据行 if (e.Row.RowType == DataControlRowType.DataRow) { if (e.Row.RowState == DataControlRowState.Normal || e.Row.RowState == DataControlRowState.Alternate) { ((LinkButton)e.Row.Cells[6].Controls[0]).Attributes.Add("onclick", "javascript:return confirm('你确认要删除:\"" + e.Row.Cells[1].Text + "\"吗?')"); } } }
------解决方案--------------------
嗯,楼上的似乎都回答了