Admin/yonghuguanli.aspx.cs
(完整代码) 1KBusing System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Data;
public partial class Admin_UserManage : System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
{
if (!IsPostBack)
{
BindData();
}
}
private void BindData()
{
//查询所有前台用户信息
string sql = "select * from [user] order by UID desc";
DataSet ds = LinkDB.Query(sql);
DataGrid1.DataSource = ds.Tables[0];
DataGrid1.DataKeyField = "UID";
DataGrid1.DataBind();
}
protected void DataGrid1_PageIndexChanged(object source, DataGridPageChangedEventArgs e)
{
this.DataGrid1.CurrentPageIndex = e.NewPageIndex;
BindData();
}
protected void DataGrid1_ItemDataBound(object sender, DataGridItemEventArgs e)
{
if (e.Item.ItemType == ListItemType.Item || e.Item.ItemType == ListItemType.AlternatingItem)
{
e.Item.Attributes.Add("onmouseover", "c=this.style.backgroundColor,this.style.backgroundColor='#6699ff'");
e.Item.Attributes.Add("onmouseout", "this.style.backgroundColor=c");
}
}
protected void DataGrid1_DeleteCommand(object source, DataGridCommandEventArgs e)
{
int index = e.Item.ItemIndex;
string id = this.DataGrid1.DataKeys[index].ToString().Trim();//获取前台用户ID
string sql;
sql = "delete from [user] where UID=" + id + " ";//根据ID删除用户信息
int result = LinkDB.ExecuteSql(sql);//执行删除语句
if (result == 1)
{
Response.Write("<script>javascript:alert('删除成功');</script>");
BindData();
}
else
{
Response.Write("<script>javascript:alert('系统错误,请检查数据库设置问题');</script>");
}
}
}
24 小时内免费解锁 3 个项目,之后 1 积分/个。 规则说明
AI 解读 AI
登录后可用,每次 10 积分,解读结果公开显示在下面。
还没有人解读过这个文件。
