DATAGRID分页问题,代码没有错误,为什么提示编译错误?!
oenpm 2003-07-17 09:03:17 **************************提示如下错误***********************************
Server Error in '/Weboffice' Application.
--------------------------------------------------------------------------------
Compilation Error
Description: An error occurred during the compilation of a resource required to service this request. Please review the following specific error details and modify your source code appropriately.
Compiler Error Message: CS0122: 'Weboffice.tpc.Pagedn(object, System.Web.UI.WebControls.DataGridPageChangedEventArgs)' is inaccessible due to its protection level
Source Error:
Line 11: <body MS_POSITIONING="GridLayout">
Line 12: <form id="tpc" method="post" runat="server">
Line 13: <asp:DataGrid id="DataGrid1" style="Z-INDEX: 101; LEFT: 272px; POSITION: absolute; TOP: 124px" runat="server" AllowPaging="True" PageSize="3" OnPageIndexChanged="Pagedn">
Line 14: <PagerStyle NextPageText="下页" PrevPageText="上页"></PagerStyle>
Line 15: </asp:DataGrid>
Source File: d:\inetpub\wwwroot\weboffice\tpc.aspx Line: 13
Show Detailed Compiler Output:
D:\WINDOWS\system32> "d:\windows\microsoft.net\framework\v1.1.4322\csc.exe" /t:library /utf8output /R:"d:\windows\assembly\gac\system.data\1.0.5000.0__b77a5c561934e089\system.data.dll" /R:"d:\windows\assembly\gac\system.enterpriseservices\1.0.5000.0__b03f5f7f11d50a3a\system.enterpriseservices.dll" /R:"d:\windows\microsoft.net\framework\v1.1.4322\temporary asp.net files\weboffice\fa30126b\ddbbd9c0\assembly\dl2\9b94bead\a0e9f076_614cc301\weboffice.dll" /R:"d:\windows\microsoft.net\framework\v1.1.4322\temporary asp.net files\weboffice\fa30126b\ddbbd9c0\lzm9z039.dll" /R:"d:\windows\microsoft.net\framework\v1.1.4322\mscorlib.dll" /R:"d:\windows\assembly\gac\system.xml\1.0.5000.0__b77a5c561934e089\system.xml.dll" /R:"d:\windows\assembly\gac\system.web.services\1.0.5000.0__b03f5f7f11d50a3a\system.web.services.dll" /R:"d:\windows\assembly\gac\system\1.0.5000.0__b77a5c561934e089\system.dll" /R:"d:\windows\assembly\gac\system.web\1.0.5000.0__b03f5f7f11d50a3a\system.web.dll" /R:"d:\windows\assembly\gac\system.drawing\1.0.5000.0__b03f5f7f11d50a3a\system.drawing.dll" /R:"d:\windows\assembly\gac\system.web.mobile\1.0.5000.0__b03f5f7f11d50a3a\system.web.mobile.dll" /out:"D:\WINDOWS\Microsoft.NET\Framework\v1.1.4322\Temporary ASP.NET Files\weboffice\fa30126b\ddbbd9c0\yyt6ykcv.dll" /D:DEBUG /debug+ /optimize- /win32res:"D:\WINDOWS\Microsoft.NET\Framework\v1.1.4322\Temporary ASP.NET Files\weboffice\fa30126b\ddbbd9c0\yyt6ykcv.res" /warnaserror /w:1 "D:\WINDOWS\Microsoft.NET\Framework\v1.1.4322\Temporary ASP.NET Files\weboffice\fa30126b\ddbbd9c0\yyt6ykcv.0.cs"
Microsoft (R) Visual C# .NET Compiler version 7.10.3052.4
for Microsoft (R) .NET Framework version 1.1.4322
Copyright (C) Microsoft Corporation 2001-2002. All rights reserved.
d:\inetpub\wwwroot\weboffice\tpc.aspx(13,102): error CS0122: 'Weboffice.tpc.Pagedn(object, System.Web.UI.WebControls.DataGridPageChangedEventArgs)' is inaccessible due to its protection level
d:\inetpub\wwwroot\weboffice\tpc.aspx(13,102): error CS0122: 'Weboffice.tpc.Pagedn(object, System.Web.UI.WebControls.DataGridPageChangedEventArgs)' is inaccessible due to its protection level
*************************************************************************
*************************HTML代码如下***********************************
<%@ Page language="c#" Codebehind="tpc.aspx.cs" AutoEventWireup="false" Inherits="Weboffice.tpc" %>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN" >
<HTML>
<HEAD>
<title>tpc</title>
<meta name="GENERATOR" Content="Microsoft Visual Studio 7.0">
<meta name="CODE_LANGUAGE" Content="C#">
<meta name="vs_defaultClientScript" content="JavaScript">
<meta name="vs_targetSchema" content="http://schemas.microsoft.com/intellisense/ie5">
</HEAD>
<body MS_POSITIONING="GridLayout">
<form id="tpc" method="post" runat="server">
<asp:DataGrid id="DataGrid1" style="Z-INDEX: 101; LEFT: 272px; POSITION: absolute; TOP: 124px" runat="server" AllowPaging="True" PageSize="3" OnPageIndexChanged="Pagedn">
<PagerStyle NextPageText="下页" PrevPageText="上页"></PagerStyle>
</asp:DataGrid>
</form>
</body>
</HTML>
************************************************************************
****************************CS文件如下**********************************
using System;
using System.Collections;
using System.ComponentModel;
using System.Data;
using System.Data.SqlClient;
using System.Drawing;
using System.Web;
using System.Web.SessionState;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.HtmlControls;
namespace Weboffice
{
/// <summary>
/// tpc 的摘要说明。
/// </summary>
public class tpc : System.Web.UI.Page
{
protected System.Web.UI.WebControls.DataGrid DataGrid1;
private void Page_Load(object sender, System.EventArgs e)
{
if(!Page.IsPostBack)
{
LoadData();
}
//DataGrid1.PageIndexChanged=Pagedn();
//this.DataGrid1.CurrentPageIndex = e.NewPageIndex;
//LoadData();
// 在此处放置用户代码以初始化页面
}
private void Pagedn(object sender,System.Web.UI.WebControls.DataGridPageChangedEventArgs e)
{
DataGrid1.CurrentPageIndex=e.NewPageIndex;
LoadData();
}
private void LoadData()
{
SqlConnection ds=new SqlConnection(System.Configuration.ConfigurationSettings.AppSettings["ConnString"]);
string dd="select * from [user]";
SqlDataAdapter obj=new SqlDataAdapter(dd,ds);
DataSet obj1=new DataSet();
obj.Fill(obj1,"dstable");
DataGrid1.PagerStyle.NextPageText="NEXT";
DataGrid1.PagerStyle.PrevPageText="pr";
DataGrid1.DataSource=obj1.Tables["dstable"];
DataGrid1.DataBind();
//ds.Close();
}
private void DataGrid1_PageIndexChanged(object sender, System.Web.UI.WebControls.DataGridPageChangedEventArgs e)
{
DataGrid1.CurrentPageIndex = e.NewPageIndex;
LoadData();
}
#region Web Form Designer generated code
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
private void DataGrid1_SelectedIndexChanged(object sender, System.EventArgs e)
{
}
}
}
*************************************************************************
*************************************************************************
*************************************************************************
*************************************************************************
不知道为什么?请给个提示