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)
{

}
}
}
*************************************************************************
*************************************************************************
*************************************************************************
*************************************************************************

不知道为什么?请给个提示


...全文
18 5 打赏 收藏 举报
写回复
5 条回复
切换为时间正序
当前发帖距今超过3年,不再开放新的回复
发表回复
crodling 2003-07-18
  • 打赏
  • 举报
回复
我想你这里的Pagedn是private,外面当然不能访问。
oenpm 2003-07-17
  • 打赏
  • 举报
回复
crodling(蓝风) 兄的方法管用,不过原因是什么,请 crodling(蓝风) 兄指教一下可以吗?
xhan2000 2003-07-17
  • 打赏
  • 举报
回复
<form id="tpc" method="post" runat="server">

换成

<form id="Form1" method="post" runat="server">
crodling 2003-07-17
  • 打赏
  • 举报
回复
不过你下面不是已经定义了PageIndexChanged事件了么?
crodling 2003-07-17
  • 打赏
  • 举报
回复
private void Pagedn
改成
public 呢?
相关推荐
发帖
.NET社区

6.1w+

社区成员

.NET技术交流专区
javascript云原生 企业社区
社区管理员
  • ASP.NET
  • .Net开发者社区
  • R小R
加入社区
帖子事件
创建了帖子
2003-07-17 09:03
社区公告

.NET 社区是一个围绕开源 .NET 的开放、热情、创新、包容的技术社区。社区致力于为广大 .NET 爱好者提供一个良好的知识共享、协同互助的 .NET 技术交流环境。我们尊重不同意见,支持健康理性的辩论和互动,反对歧视和攻击。

希望和大家一起共同营造一个活跃、友好的社区氛围。