inaccessible due to its protection level - Programmers Heaven

Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

Categories

inaccessible due to its protection level

ac77ac77 Posts: 1Member
I've been having great difficulty with this, so hopefully someone more knowledgeable than myself can help out.

I'm basically trying to create a data grid from a code behind file. I have a file called index.aspx and a code behind file called ThePageBase.cs. In addition I have a namspace called DCTM in which I encapsulate my business logic and data access logic.

My code works great, but it breaks when I try and add paging using the following line:

mygrid.OnPageIndexChanged="change_Page";

The error is as follows:

Compiler Error Message: CS0122: 'System.Web.UI.WebControls.DataGrid.OnPageIndexChanged(System.Web.UI.WebControls.DataGridPageChangedEventArgs)' is inaccessible due to its protection level


I'm not sure what I need to do. For the sake of debugging I declared everything in my code behind file to be public. Below is what my code looks like:

index.aspx
---------
<%@ Page Language="C#" Inherits="ThePageBase" src="ThePageBase.cs" ContentType="text/html" ResponseEncoding="iso-8859-1" %>



-----



ThePageBase.cs
--------------

using System;
using System.Web;
using System.Web.UI;

using System.Web.UI.HtmlControls;
using System.Web.UI.WebControls;
using System.Data;
using System.Data.OleDb;
using System.Text;
using System.Net;
using System.IO;
using System.Drawing;

using DCTM;


public class ThePageBase : System.Web.UI.Page {

public HtmlForm myform;
public DataGrid mygrid = new DataGrid();
protected Label TheResult;

public void Page_Load(Object Source, EventArgs E) {

if (!IsPostBack) {
CreateBindData();
}
}

void CreateBindData() {

BizObject bus = new BizObject("Provider=OraOLEDB.Oracle;Data Source=mysourse;User Id=myuser;Password=mypass");
DataSet ds = bus.GetData();
myform.Controls.Add(MakeGrid(ds));
}

public DataGrid MakeGrid(DataSet datas) {

mygrid.CellPadding=5;
mygrid.CellSpacing=1;
mygrid.BorderWidth=1;
mygrid.Width=550;
mygrid.BorderWidth=0;
mygrid.Font.Size=8;
mygrid.Font.Name="Arial";
mygrid.AutoGenerateColumns=false;
mygrid.EnableViewState=true;

BoundColumn Title = new BoundColumn();
BoundColumn Location = new BoundColumn();
BoundColumn EventType = new BoundColumn();

Title.HeaderText="Title";
Title.DataField="TITLE";
Location.HeaderText="Location";
Location.DataField="EVENT_LOCATION";
EventType.HeaderText="Type";
EventType.DataField="EVENT_TYPE";

mygrid.Columns.AddAt(0, Title);
mygrid.Columns.AddAt(1, Location);
mygrid.Columns.AddAt(2, EventType);

mygrid.HeaderStyle.HorizontalAlign=HorizontalAlign.Left;
mygrid.HeaderStyle.Font.Bold=true;
mygrid.HeaderStyle.BackColor=ColorTranslator.FromHtml("White");
mygrid.HeaderStyle.ForeColor=ColorTranslator.FromHtml("Black");

mygrid.ItemStyle.BackColor=ColorTranslator.FromHtml("#DAE7F7");
mygrid.AlternatingItemStyle.BackColor=ColorTranslator.FromHtml("#C8D5E5");

mygrid.AllowPaging=true;
mygrid.PageSize=10;
mygrid.OnPageIndexChanged="change_Page";
mygrid.PagerStyle.Mode = PagerMode.NextPrev;
mygrid.PagerStyle.NextPageText="next";
mygrid.PagerStyle.PrevPageText="previous";

mygrid.DataSource = datas;
mygrid.DataBind();
return mygrid;
}

public void change_Page(Object sender, DataGridPageChangedEventArgs e) {

mygrid.CurrentPageIndex = e.NewPageIndex;
CreateBindData();
}


// output html page with template
protected override void Render(HtmlTextWriter writer) {
writer.Write( @" Careers ");
writer.Write( readHtmlPage("http://mysite/templates/master/head.asp") );
writer.Write( @"
" );

base.Render( writer );

writer.Write( @"
" );
writer.Write( readHtmlPage("http:/mysite/templates/master/tail.asp") );
}


private String readHtmlPage(string url) {
WebResponse objResponse;
WebRequest objRequest = System.Net.HttpWebRequest.Create(url);
objResponse = objRequest.GetResponse();
StreamReader sr = new StreamReader(objResponse.GetResponseStream());
return sr.ReadToEnd();
}

}

---------------


Thanks!!!

Comments

Sign In or Register to comment.