示例#1
0
        protected void gvUsers_RowDeleting(object sender, GridViewDeleteEventArgs e)
        {
            UsersDataContext lq = new UsersDataContext();
            var users           = from gt in lq.Users where gt.uID == Convert.ToInt32(gvUsers.DataKeys[e.RowIndex].Value) select gt;

            foreach (Users user in users)
            {
                lq.Users.DeleteOnSubmit(user);
            }
            lq.SubmitChanges();
            Response.Redirect("UsersManager.aspx");
        }
示例#2
0
 protected void Page_Load(object sender, EventArgs e)
 {
     if (Session["AdminName"] != null)
     {
         UsersDataContext lq = new UsersDataContext();
         var mylq            = from gt in lq.Users select gt;
         gvUsers.DataSource = mylq;
         gvUsers.DataBind();
     }
     else
     {
         ClientScript.RegisterStartupScript(GetType(), "", "<script>alert('请先登录!');location.href='../AdminsManager/AdminLogin.aspx';</script>");
     }
 }