示例#1
0
        protected void Page_Load(object sender, EventArgs e)
        {
            Bll.UserInfoBll userInfoBll = new Bll.UserInfoBll();
            List <UserInfo> list        = userInfoBll.GetList();

            UserList = list;
            //StringBuilder sb = new StringBuilder();
            //foreach (UserInfo userinfo in list)
            //{
            //    sb.AppendFormat("<tr><td>{0}</td><td>{1}</td><td>{2}</td><td>{3}</td></tr>",userinfo.UserId,userinfo.UserName,userinfo.UserPwd,userinfo.RegTime.ToShortDateString());
            //    StrHtml = sb.ToString();
            //}
        }
示例#2
0
 protected void Page_Load(object sender, EventArgs e)
 {
     //判断缓存中是否有数据
     if (Cache["userInfoList"] == null)
     {
         Bll.UserInfoBll userInfoBll = new Bll.UserInfoBll();
         List <UserInfo> list        = userInfoBll.GetList();
         //将数据放到缓存中
         Cache["userInfoList"] = list;
         Response.Write("数据来自数据库");
     }
     else
     {
         List <UserInfo> list = (List <UserInfo>)Cache["userInfoList"];
         Response.Write("数据来自缓存");
     }
 }
示例#3
0
        public void ProcessRequest(HttpContext context)
        {
            context.Response.ContentType = "text/html";
            Bll.UserInfoBll UserInfoService = new Bll.UserInfoBll();
            List <UserInfo> list            = UserInfoService.GetList();
            StringBuilder   sb = new StringBuilder();

            foreach (UserInfo userinfo in list)
            {
                sb.AppendFormat("<tr><td>{0}</td><td>{1}</td><td>{2}</td><td>{3}</td><td>{4}</td><td><a href='ShowDetail.ashx?id={0}'>详细</a></td><td><a href='UserDelet.ashx?uid={0}'class=deletes>删除</a></td><td><a href='ShowEdit.ashx?id={0}'>编辑</a></td></tr>", userinfo.UserId, userinfo.UserName, userinfo.UserPwd, userinfo.Email, userinfo.RegTime);
            }
            //读取模板文件
            string filePath    = context.Request.MapPath("UserInfoList.html");
            string fileContent = File.ReadAllText(filePath);

            fileContent = fileContent.Replace("@tbody", sb.ToString());
            context.Response.Write(fileContent);
        }