本人是初学者,想请教高手分页问题!
stkey 2008-11-25 03:11:56 <%@ Page language="c#" Codebehind="index.aspx.cs" AutoEventWireup="false" Inherits="Web.index" %>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN" >
<HTML>
<HEAD>
<title>index</title>
<meta content="True" name="vs_showGrid">
<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">
</HEAD>
<body MS_POSITIONING="GridLayout">
<form id="Form1" method="post" runat="server">
<FONT face="宋体">
<asp:datagrid id="DataGrid1" style="Z-INDEX: 101; LEFT: 32px; POSITION: absolute; TOP: 24px" runat="server"
Width="792px" Height="24px" AutoGenerateColumns="False" BorderColor="#CC9966" BorderStyle="None"
BorderWidth="1px" BackColor="White" CellPadding="4" PageSize="2" AllowCustomPaging="True">
<SelectedItemStyle Font-Bold="True" ForeColor="#663399" BackColor="#FFCC66"></SelectedItemStyle>
<ItemStyle ForeColor="#330099" BackColor="White"></ItemStyle>
<HeaderStyle Font-Bold="True" ForeColor="#FFFFCC" BackColor="#990000"></HeaderStyle>
<FooterStyle ForeColor="#330099" BackColor="#FFFFCC"></FooterStyle>
<Columns>
<asp:TemplateColumn>
<ItemTemplate>
<A href='edit.aspx?id=<%#DataBinder.Eval(Container.DataItem,"n_id")%>' target=_blank>
编辑</A> <A href='view.aspx?id=<%#DataBinder.Eval(Container.DataItem,"n_id")%>' target=_blank>
<%#DataBinder.Eval(Container.DataItem,"n_title")%>
</A>
</ItemTemplate>
</asp:TemplateColumn>
</Columns>
</asp:datagrid></FONT></form>
</body>
</HTML>
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 Socut.Data;//引用命名空间
namespace Web
{
/// <summary>
/// index 的摘要说明。
/// </summary>
public class index : System.Web.UI.Page
{
protected System.Web.UI.WebControls.DataGrid DataGrid1;
public CData myData=new CData ();//调用组件中的类CData
public DataSet ds=new DataSet();//将DataSet实例化
private void Page_Load(object sender, System.EventArgs e)
{
ds=myData.GetDataSet ("SELECT * FROM socut_news",0,0,"Tablename");
DataGrid1.DataSource=ds;//设置数据源
DataGrid1.DataBind();//绑定数据
}
#region Web 窗体设计器生成的代码
override protected void OnInit(EventArgs e)
{
//
// CODEGEN: 该调用是 ASP.NET Web 窗体设计器所必需的。
//
InitializeComponent();
base.OnInit(e);
}
/// <summary>
/// 设计器支持所需的方法 - 不要使用代码编辑器修改
/// 此方法的内容。
/// </summary>
private void InitializeComponent()
{
this.DataGrid1.SelectedIndexChanged += new System.EventHandler(this.DataGrid1_SelectedIndexChanged);
this.Load += new System.EventHandler(this.Page_Load);
}
#endregion
}
}
这样如何写分页的代码呢?