aspx文件
=============================
![](/Images/OutliningIndicators/ExpandedBlockStart.gif)
<%
@ Page language="c#" Codebehind="userlist.aspx.cs" AutoEventWireup="false" Inherits="admin.userlist" %>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN" >
<HTML>
<HEAD>
<title>userlist</title>
<meta content=" Microsoft Visual Studio .NET 7.1" name="GENERATOR">
<meta content="C#" name="CODE_LANGUAGE">
<meta content="JavaScript" name="vs_defaultClientScript">
<meta content="http://schemas.microsoft.com/intellisense/ie5" name="vs_targetSchema">
<LINK href="../images/css_admin.css" type="text/css" rel="stylesheet">
</HEAD>
<body bgColor="#ffeef7">
<%=script%>
<form id="Form1" method="post" runat="server">
<div align="center">
<table cellSpacing="0" cellPadding="0" width="100%" border="0">
<tr>
<td width="100%">
<div align="center">
<table height="20" cellSpacing="0" cellPadding="0" width="100%" bgColor="#d6e7ef" border="0">
<tr>
<td width="100%">
<hr width="90%" SIZE="1">
</td>
</tr>
</table>
</div>
</td>
</tr>
</table>
</div>
<DIV align="center">注册会员管理:</DIV>
<div align="center">
<table height="40" cellSpacing="0" cellPadding="0" width="96%" border="0">
<tr>
<td align="center" width="100%">会员搜索:
<asp:dropdownlist id="DdlSearchType" runat="server" Height="16px" Width="110px">
<asp:LIstItem Value="1">按会员名称搜索</asp:LIstItem>
<asp:ListItem Value="2">按会员ID搜索</asp:ListItem>
</asp:dropdownlist><asp:textbox id="TxtSearchValue" runat="server"></asp:textbox>
<asp:button id="BtnSub" runat="server" Text="提交"></asp:button></td>
</tr>
</table>
</div>
<div align="center"><asp:datagrid id="DgUserList" runat="server" Width="96%" AllowPaging="True" PageSize="30" PagerStyle-HorizontalAlign="Right"
PagerStyle-Height="30" HeaderStyle-Height="25" ItemStyle-Height="25" AutoGenerateColumns="False" BorderColor="Firebrick"
BorderWidth="1px" CellPadding="0">
<AlternatingItemStyle BackColor="Azure"></AlternatingItemStyle>
<ItemStyle Height="25px"></ItemStyle>
<HeaderStyle HorizontalAlign="Center" Height="25px" BackColor="LightPink"></HeaderStyle>
<Columns>
<asp:TemplateColumn HeaderText="是否交费">
<ItemStyle HorizontalAlign="Center"></ItemStyle>
<ItemTemplate>
![](/Images/OutliningIndicators/ExpandedBlockStart.gif)
<%
# DataBinder.Eval(Container.DataItem, "SFJFSORTNAME")%>
</ItemTemplate>
</asp:TemplateColumn>
<asp:TemplateColumn HeaderText="注册会员ID">
<ItemTemplate>
![](/Images/OutliningIndicators/ExpandedBlockStart.gif)
<%
# DataBinder.Eval(Container.DataItem, "YJSID")%>
</ItemTemplate>
</asp:TemplateColumn>
<asp:TemplateColumn HeaderText="姓名">
<ItemTemplate>
![](/Images/OutliningIndicators/ExpandedBlockStart.gif)
<%
# DataBinder.Eval(Container.DataItem, "YJSNAME")%>
</ItemTemplate>
</asp:TemplateColumn>
<asp:TemplateColumn HeaderText="类别">
<ItemStyle HorizontalAlign="Center"></ItemStyle>
<ItemTemplate>
![](/Images/OutliningIndicators/ExpandedBlockStart.gif)
<%
# DataBinder.Eval(Container.DataItem, "YJSSORTNAME")%>
</ItemTemplate>
</asp:TemplateColumn>
<asp:TemplateColumn HeaderText="加入时间">
<ItemStyle HorizontalAlign="Center"></ItemStyle>
<ItemTemplate>
![](/Images/OutliningIndicators/ExpandedBlockStart.gif)
<%
# DataBinder.Eval(Container.DataItem, "REGTIME")%>
</ItemTemplate>
</asp:TemplateColumn>
<asp:TemplateColumn HeaderText="操作">
<ItemStyle HorizontalAlign="Center"></ItemStyle>
<ItemTemplate>
<a href='UserMod.aspx?yjsid=<%# DataBinder.Eval(Container.DataItem, "YJSID")%>'>更改</a>
</ItemTemplate>
</asp:TemplateColumn>
</Columns>
<PagerStyle Height="30px" HorizontalAlign="Right" Mode="NumericPages"></PagerStyle>
</asp:datagrid></div>
<div align="center">
<TABLE id="Table1" cellSpacing="0" cellPadding="0" width="96%" align="center" bgColor="#ffffff"
border="0">
<TR>
<TD align="center" height="30">记录数:
<asp:label id="LblRecordCount" runat="server">记录数</asp:label>;页次:
<asp:label id="LblCurrentIndex" runat="server">当前页</asp:label>/
<asp:label id="LblPageCount" runat="server">总页数</asp:label>; 【<asp:linkbutton id="BtnFirst" CommandArgument="first" runat="server">首页</asp:linkbutton>】
【<asp:linkbutton id="BtnPrev" CommandArgument="prev" runat="server">上一页</asp:linkbutton><%=prev%>】
【<asp:linkbutton id="BtnNext" CommandArgument="next" runat="server">下一页</asp:linkbutton><%=next%>】
【<asp:linkbutton id="BtnLast" CommandArgument="last" runat="server">尾页</asp:linkbutton>】
跳转:<asp:TextBox id="TxtJump" runat="server" Width="30px"></asp:TextBox>
<asp:Button id="BtnJumpSub" runat="server" Width="30px" Text="GO" Height="22px"></asp:Button>
</TD>
</TR>
</TABLE>
</div>
</form>
<br>
<br>
</body>
</HTML>
![](/Images/OutliningIndicators/None.gif)
===========================================
cs文件
===========================================
using System;
using System.Collections;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Web;
using System.Web.SessionState;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.HtmlControls;
using DataAccess;
using Entity;
![](/Images/OutliningIndicators/None.gif)
namespace admin
![](/Images/OutliningIndicators/ExpandedBlockStart.gif)
![](/Images/OutliningIndicators/ContractedBlock.gif)
{
![](/Images/OutliningIndicators/ExpandedSubBlockStart.gif)
/**//// <summary>
/// userlist 的摘要说明。
/// </summary>
public class userlist : System.Web.UI.Page
![](/Images/OutliningIndicators/ExpandedSubBlockStart.gif)
{
protected System.Web.UI.WebControls.DropDownList DdlSearchType;
protected System.Web.UI.WebControls.Button BtnSub;
protected System.Web.UI.WebControls.DataGrid DgUserList;
protected System.Web.UI.WebControls.Label LblRecordCount;
protected System.Web.UI.WebControls.Label LblCurrentIndex;
protected System.Web.UI.WebControls.Label LblPageCount;
protected System.Web.UI.WebControls.LinkButton BtnFirst;
protected System.Web.UI.WebControls.LinkButton BtnPrev;
protected System.Web.UI.WebControls.LinkButton BtnNext;
protected System.Web.UI.WebControls.LinkButton BtnLast;
protected System.Web.UI.WebControls.TextBox TxtSearchValue;
protected int RecordCount;//记录总数
protected int PageCount;//页面总数
protected string prev;
protected string next;
protected System.Web.UI.WebControls.TextBox TxtJump;
protected System.Web.UI.WebControls.Button BtnJumpSub;
protected string script;
private void Page_Load(object sender, System.EventArgs e)
![](/Images/OutliningIndicators/ExpandedSubBlockStart.gif)
{
// 在此处放置用户代码以初始化页面
//-管理员判断----------------------------------
HttpCookie cokAdminName=new HttpCookie("CokAdminName");
HttpCookie cokAdminPs=new HttpCookie("CokAdminPs");
cokAdminName=Request.Cookies["CokAdminName"];
cokAdminPs=Request.Cookies["CokAdminPs"];
AdminLogin adLog=new AdminLogin(cokAdminName.Value ,cokAdminPs.Value );
if(!adLog.login())
![](/Images/OutliningIndicators/ExpandedSubBlockStart.gif)
{
Response.Redirect("adminloginerror.aspx",true);
}
//----------------------------------------------
![](/Images/OutliningIndicators/InBlock.gif)
if(!Page.IsPostBack)
![](/Images/OutliningIndicators/ExpandedSubBlockStart.gif)
{
this.DispUserList();
this.ShowStats();
}
}
![](/Images/OutliningIndicators/InBlock.gif)
//-DATAGRID链接事件------------------------------------------------------------------------------
private void DgUserList_PageIndexChanged(object source, System.Web.UI.WebControls.DataGridPageChangedEventArgs e)
![](/Images/OutliningIndicators/ExpandedSubBlockStart.gif)
{
this.DgUserList.CurrentPageIndex=e.NewPageIndex;
this.DispUserList();
this.ShowStats();
![](/Images/OutliningIndicators/InBlock.gif)
}
//------------------------------------------------------------------------------------------------
![](/Images/OutliningIndicators/InBlock.gif)
//-PageBtn_Click()事件--------------------------------------------------------------------------
private void PageBtn_Click(object sender, System.EventArgs e)
![](/Images/OutliningIndicators/ExpandedSubBlockStart.gif)
{
string btn=((LinkButton)sender).CommandArgument.ToString();
switch(btn)
![](/Images/OutliningIndicators/ExpandedSubBlockStart.gif)
{
case "first":
this.DgUserList.CurrentPageIndex=0;
break;
case "last":
if(this.DgUserList.PageCount==0)
![](/Images/OutliningIndicators/ExpandedSubBlockStart.gif)
{
this.DgUserList.CurrentPageIndex=this.DgUserList.PageCount;
}
else
![](/Images/OutliningIndicators/ExpandedSubBlockStart.gif)
{
this.DgUserList.CurrentPageIndex=this.DgUserList.PageCount-1;
}
break;
case "prev":
this.DgUserList.CurrentPageIndex-=1;
break;
case "next":
this.DgUserList.CurrentPageIndex+=1;
break;
}
this.DispUserList();
this.ShowStats();
}
//------------------------------------------------------------------------------------------------
![](/Images/OutliningIndicators/InBlock.gif)
//-跳转页面事件------------------------------------------------------------------------------
private void BtnJumpSub_Click(object sender, System.EventArgs e)
![](/Images/OutliningIndicators/ExpandedSubBlockStart.gif)
{
try
![](/Images/OutliningIndicators/ExpandedSubBlockStart.gif)
{
if(System.Convert.ToInt32(this.TxtJump.Text.ToString())<0||System.Convert.ToInt32(this.TxtJump.Text.ToString())>this.DgUserList.PageCount)
![](/Images/OutliningIndicators/ExpandedSubBlockStart.gif)
{
script+="<script language=javascript>alert('请输入正确的页数!')</script>";
this.DispUserList();
this.ShowStats();
this.TxtJump.Text="";
}
else
![](/Images/OutliningIndicators/ExpandedSubBlockStart.gif)
{
this.DgUserList.CurrentPageIndex=System.Convert.ToInt32(this.TxtJump.Text.ToString())-1;
this.DispUserList();
this.ShowStats();
}
}
catch
![](/Images/OutliningIndicators/ExpandedSubBlockStart.gif)
{
script+="<script language=javascript>alert('请输入正确的页数!')</script>";
this.DispUserList();
this.ShowStats();
this.TxtJump.Text="";
}
![](/Images/OutliningIndicators/InBlock.gif)
}
//-------------------------------------------------------------------------------------------
![](/Images/OutliningIndicators/InBlock.gif)
//-搜索事件-----------------------------------------------------------------------------------------
private void BtnSub_Click(object sender, System.EventArgs e)
![](/Images/OutliningIndicators/ExpandedSubBlockStart.gif)
{
this.DgUserList.CurrentPageIndex=0;
this.DispUserList();
this.ShowStats();
}
//--------------------------------------------------------------------------------------------------
![](/Images/OutliningIndicators/InBlock.gif)
//-绑定DataGrid,DispUserList()---------------------------------------------
public void DispUserList()
![](/Images/OutliningIndicators/ExpandedSubBlockStart.gif)
{
DataSet ds=OracleSelect.GetUserList(System.Convert.ToInt32(this.DdlSearchType.SelectedItem.Value.ToString()),this.TxtSearchValue.Text.ToString());
if(ds.Tables.Count>0)
![](/Images/OutliningIndicators/ExpandedSubBlockStart.gif)
{
if(ds.Tables[0].Rows.Count>0)
![](/Images/OutliningIndicators/ExpandedSubBlockStart.gif)
{
this.DgUserList.DataSource=ds;
this.DgUserList.DataBind();
this.RecordCount=ds.Tables[0].Rows.Count;//计算记录总数
}
else
![](/Images/OutliningIndicators/ExpandedSubBlockStart.gif)
{
this.script+="<script language=javascript>alert('sorry,没有找到相关记录!')</script>";
}
}
![](/Images/OutliningIndicators/InBlock.gif)
}
//----------------------------------------------------------
![](/Images/OutliningIndicators/InBlock.gif)
//-统计记录 ShowStats()-------------------------------------------------
public void ShowStats()
![](/Images/OutliningIndicators/ExpandedSubBlockStart.gif)
{
this.LblRecordCount.Text=this.RecordCount.ToString();
this.LblCurrentIndex.Text=(this.DgUserList.CurrentPageIndex+1).ToString();
this.LblPageCount.Text=this.DgUserList.PageCount.ToString();
this.PageCount=this.DgUserList.PageCount;//计算页面总数
this.ShowPrevNext((this.DgUserList.CurrentPageIndex+1),this.DgUserList.PageCount);
}
![](/Images/OutliningIndicators/InBlock.gif)
![](/Images/OutliningIndicators/InBlock.gif)
//-是否显示上一页,下一页链接ShowPrevNext()----------------------------------------------------------------------
public void ShowPrevNext(int currentPage,int pageCount)
![](/Images/OutliningIndicators/ExpandedSubBlockStart.gif)
{
if(pageCount==1)
![](/Images/OutliningIndicators/ExpandedSubBlockStart.gif)
{
this.prev="<font color=888888>上一页</font>";
this.next="<font color=888888>下一页</font>";
this.BtnPrev.Visible=false;
this.BtnNext.Visible=false;
}
else
![](/Images/OutliningIndicators/ExpandedSubBlockStart.gif)
{
if(currentPage==1)
![](/Images/OutliningIndicators/ExpandedSubBlockStart.gif)
{
this.prev="<font color=888888>上一页</font>";
this.BtnPrev.Visible=false;
this.next="";
this.BtnNext.Visible=true;
}
else
![](/Images/OutliningIndicators/ExpandedSubBlockStart.gif)
{
if(currentPage==this.PageCount)
![](/Images/OutliningIndicators/ExpandedSubBlockStart.gif)
{
this.next="<font color=888888>下一页</font>";
this.BtnNext.Visible=false;
this.prev="";
this.BtnPrev.Visible=true;
}
else
![](/Images/OutliningIndicators/ExpandedSubBlockStart.gif)
{
this.prev="";
this.next="";
this.BtnPrev.Visible=true;
this.BtnNext.Visible=true;
}
}
}
}
//-------------------------------------------------------------------------------------------------
![](/Images/OutliningIndicators/InBlock.gif)
![](/Images/OutliningIndicators/InBlock.gif)
![](/Images/OutliningIndicators/ContractedSubBlock.gif)
Web 窗体设计器生成的代码#region Web 窗体设计器生成的代码
override protected void OnInit(EventArgs e)
![](/Images/OutliningIndicators/ExpandedSubBlockStart.gif)
{
//
// CODEGEN: 该调用是 ASP.NET Web 窗体设计器所必需的。
//
InitializeComponent();
base.OnInit(e);
}
![](/Images/OutliningIndicators/ExpandedSubBlockStart.gif)
/**//// <summary>
/// 设计器支持所需的方法 - 不要使用代码编辑器修改
/// 此方法的内容。
/// </summary>
private void InitializeComponent()
![](/Images/OutliningIndicators/ExpandedSubBlockStart.gif)
{
this.BtnSub.Click += new System.EventHandler(this.BtnSub_Click);
this.DgUserList.PageIndexChanged += new System.Web.UI.WebControls.DataGridPageChangedEventHandler(this.DgUserList_PageIndexChanged);
this.BtnFirst.Click += new System.EventHandler(this.PageBtn_Click);
this.BtnPrev.Click += new System.EventHandler(this.PageBtn_Click);
this.BtnNext.Click += new System.EventHandler(this.PageBtn_Click);
this.BtnLast.Click += new System.EventHandler(this.PageBtn_Click);
this.BtnJumpSub.Click += new System.EventHandler(this.BtnJumpSub_Click);
this.Load += new System.EventHandler(this.Page_Load);
![](/Images/OutliningIndicators/InBlock.gif)
}
#endregion
![](/Images/OutliningIndicators/InBlock.gif)
}
}
![](/Images/OutliningIndicators/None.gif)
===============================