gridview添加这个事件:
protected void GridViewTable_RowDataBound(object sender, GridViewRowEventArgs e)
{
if (e.Row.RowType == DataControlRowType.DataRow)
e.Row.Cells["删除列所在的号"].Attributes.Add("onclick", "javascript:return confirm('你确认要删除吗?')");
}
protected void GridViewTable_RowDataBound(object sender, GridViewRowEventArgs e)
{
if (e.Row.RowType == DataControlRowType.DataRow)
e.Row.Cells["删除列所在的号"].Attributes.Add("onclick", "javascript:return confirm('你确认要删除吗?')");
}
{
if (e.Row.RowIndex >= 0)
{
LinkButton delBtn = (LinkButton)e.Row.Cells[3].Controls[0];
e.Row.Attributes.Add("onmouseover", "this.style.backgroundColor='#e7e7e7'");
e.Row.Attributes.Add("onmouseout", "this.style.backgroundColor='#f7f7f7'");
delBtn.Attributes.Add("onclick", "javascript:return confirm('确定删除用户 " + e.Row.Cells[0].Text + "?');");
}
}
function ConfirmDelete()
{
return window.confirm("确认删除?");
}
{
if (e.CommandName == "Del")
{
int index = Convert.ToInt32(e.CommandArgument);
if (index >= 0)
{
WanUserEntity wue = new WanUserEntity();
wue.ID = Convert.ToInt32(gvUserInfo.DataKeys[index].Value.ToString());
wue.Mid = gvUserInfo.Rows[index].Cells[0].Text;
wue.CreateUser = gvUserInfo.Rows[index].Cells[1].Text;
wue.CreateDate = Convert.ToDateTime(gvUserInfo.Rows[index].Cells[2].Text);
WanUserProvider wup = new WanUserProvider();
if (wup.ExistMid(wue.Mid))
{
WanUserEntityAction.CreateUpdateDelete_WanUser(DataAction.Delete, wue);
MessageBox.MsgShow(this, "删除成功!");
InitPage();
}
else
{
MessageBox.MsgShow(this, "该用户不存在!");
}
}
}
}