日期:2008-09-28 浏览次数:20461 次
如果需要考虑如时间的过滤、其他条件的加入,可以在SQL语句进行编辑,普通的网站,下面的数据浏览分页
就可以了。
aspx代码:
<%@ Page language="c#" Codebehind="StockOrderFormBrower.aspx.cs" AutoEventWireup="false" Inherits="GSP.StockOrderFormBrower" %>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN" >
<HTML>
<HEAD>
<title>
用C#和SQL结合进行数据浏览分页
</title>
<LINK href="css/main.css" type="text/css" rel="stylesheet">
<meta http-equiv="Content-Type" content="text/html; charset=GB2312">
<meta content="Microsoft Visual Studio .NET 7.1" name="GENERATOR">
<meta content="C#" name="CODE_LANGUAGE">
<meta content="JavaScript" name="vs_defaultClientScript">
</HEAD>
<body MS_POSITIONING="GridLayout">
<form id="form1" method="post" runat="server">
<table id="ShowData" cellSpacing="0" cellPadding="0" align="center" border="0">
<%ShowData();%><!--输出数据-->
</table>
<table align="right">
<tr>
<td>
<%PageLoad_Count();%>
<INPUT id="first" type="button" value=" |< " name="first" runat="server"><!--第一页-->
<INPUT id="prior" type="button" value=" < " name="prior" runat="server"><!--上一页-->
<INPUT id="next" type="button" value=" > " name="next" runat="server"><!--下一页-->
<INPUT id="last" type="button" value=" >| " name="last" runat="server"><!--最后一页-->
</td>
</tr>
</table>
</form>
</body>
</HTML>
aspx.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 System.Data.SqlClient;
namespace ASWBLM
{
/// <summary>
///
/// </summary>
public class UnionInfo : System.Web.UI.Page
{
protected System.Web.UI.HtmlControls.HtmlInputButton first;
protected System.Web.UI.HtmlControls.HtmlInputButton prior;
protected System.Web.UI.HtmlControls.HtmlInputButton last;
protected System.Web.UI.HtmlControls.HtmlInputButton next;
protected static int CurrentPage = 1;//初始化开始页面
protected static int RowCount = 0 ;//本页有多少条
private static bool IsPrior = false;//有“前一页”
private static bool IsNext = false;//有“下一页”
private static bool IsLast = false;//有“最后一页”
protected static int not_shown_records=0;//计算未显示记录数
private static string startID = "";//设置上一页开始ID
private static string endID = "";//设置下一页结束ID
private static int page_count = 10;//初始化页面记录数
private void Page_Load(object sender, System.EventArgs e)
{
// 在此处放置用户代码以初始化页面
&n