【1】:建立后台会员管理页面:user_list.aspx。在这个页面中,把数据库中的会员都以列表的形式显示出来。
aspx代码:会员管理的aspx代码和news_list.aspx代码一样,复制过去修改一下就可以了。
<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="user_list.aspx.cs" Inherits="Web.admin.user_list" %> <%@ Register Assembly="AspNetPager" Namespace="Wuqi.Webdiyer" TagPrefix="webdiyer" %> <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> <head runat="server"> <title>会员管理</title> <style type="text/css"> .style1 { width: 100%; border-style: solid; border-width: 1px; } </style> </head> <body> <form id="form1" runat="server"> <h1> <asp:Literal ID="litH1" Text="会员管理" runat="server"></asp:Literal></h1> <asp:TextBox ID="txtkey" runat="server"></asp:TextBox> <asp:Button ID="btnSearch" runat="server" Text="查询" OnClick="btnSearch_Click" /> <br /> <table class="style1" border="1px"> <tr> <td> 用户名 </td> <td> 注册时间 </td> <td> 登陆次数 </td> <td> 会员类型 </td> <td> 购物总金额 </td> <td> 账户余额 </td> <td> 操作 </td> </tr> <asp:Repeater ID="replist" runat="server"> <ItemTemplate> <tr> <td> <%#Eval("username") %> </td> <td> <%#Eval("createDate") %> </td> <td> <%#GetLoginCount(Eval("username")) %> </td> <td> <%#Eval("type").ToString()=="normal"?"普通会员":"VIP会员" %> </td> <td> </td> <td> <%#Eval("amount","{0:c}") %> </td> <td> </td> </tr> </ItemTemplate> </asp:Repeater> <tr> <td colspan="7"> <webdiyer:AspNetPager ID="anp" runat="server" CustomInfoHTML="总%PageCount%页,第%CurrentPageIndex%页/%PageCount%页" FirstPageText="首页" LastPageText="尾页" NextPageText="下一页" NumericButtonCount="5" PageSize="5" PrevPageText="上一页" ShowCustomInfoSection="Left" SubmitButtonText="GO" OnPageChanged="anp_PageChanged"> </webdiyer:AspNetPager> </td> </tr> </table> </form> </body> </html>
cs代码:同样和news_list.aspx的cs代码一样,复制过去修改一下就可以了
1:显示会员类型:
<%#Eval("type").ToString()=="normal"?"普通会员":"VIP会员" %>
前台aspx:
<%#GetLoginCount(Eval("username")) %>后台cs代码:
//获取登陆次数 public string GetLoginCount(object username) { return new MyShop.DAL.Login_logDAO().CalcCount("username='"+username+"'").ToString(); }
最终cs代码:
using System; using System.Collections.Generic; using System.Linq; using System.Web; using System.Web.UI; using System.Web.UI.WebControls; namespace Web.admin { public partial class user_list : System.Web.UI.Page { protected void Page_Load(object sender, EventArgs e) { if (!IsPostBack) { anp.RecordCount = new MyShop.DAL.UserDAO().CalcCount(GetCond()); BindRep(); } } public string GetCond() { string cond = ""; if (txtkey.Text.Trim().Length != 0) { string key = txtkey.Text.Trim(); cond = " username like '%" + key + "%'"; } return cond; } private void BindRep() { replist.DataSource = new MyShop.DAL.UserDAO().GetList("*", "createdate", "desc", anp.PageSize, anp.CurrentPageIndex, GetCond()); replist.DataBind(); } //分页事件 protected void anp_PageChanged(object sender, EventArgs e) { BindRep(); } //查询 protected void btnSearch_Click(object sender, EventArgs e) { anp.RecordCount = new MyShop.DAL.UserDAO().CalcCount(GetCond()); BindRep(); } //获取登陆次数 public string GetLoginCount(object username) { return new MyShop.DAL.Login_logDAO().CalcCount("username='"+username+"'").ToString(); } } }