Monday, March 26, 2012

Please Help - Allow Paging on Grid Properties Builder

Hi,

I'm working on a grid when the database returns ... say 100 rows. I would
like to use the Allow Page in the grid Properties, but don't really know how
to code it right. I copied some code from the help, but it doesn't really
work yet. The compiler complains on the following...

private void InitializeComponent()
{
this.gridLegalEntityEmployee.SelectedIndexChanged += new
System.EventHandler(this.gridLegalEntityEmployee_S electedIndexChanged);
this.gridLegalEntityEmployee.PageIndexChanged += new
System.EventHandler(this.gridLegalEntityEmployee_P ageIndexChanged );

this.Load += new System.EventHandler(this.Page_Load);

}

private void gridLegalEntityEmployee_PageIndexChanged( object source,
System.Web.UI.WebControls.DataGridPageChangedEvent Args e)
{
gridLegalEntityEmployee.CurrentPageIndex = e.NewPageIndex;
gridLegalEntityEmployee.DataBind();
}

=== Error ======
this.gridLegalEntityEmployee_PageIndexChanged =>
'cpNET.WebForm1.gridLegalEntityEmployee_PageIndexC hanged(object,
System.Web.UI.WebControls.DataGridPageChangedEvent Args)' does not match
delegate 'void System.EventHandler(object, System.EventArgs)'

Here is some other sniplet code

================================================== ==============
private void Page_Load(object sender, System.EventArgs e)
{
// Put user code to initialize the page here
gridLegalEntityEmployee.AllowPaging = true;
gridLegalEntityEmployee.PagerStyle.Mode = PagerMode.NumericPages;
gridLegalEntityEmployee.PagerStyle.PageButtonCount = 15;
gridLegalEntityEmployee.PageSize = 15;

LoadLegalEntityEmployeeList();

if (!Page.IsPostBack)
{
gridLegalEntityEmployee.DataBind();
}
}

private void LoadLegalEntityEmployeeList()
{
LegalEntityEmployee leEmployee = new LegalEntityEmployee();

// Retrieve data from database
gridLegalEntityEmployee.DataSource = leEmployee.SelectAll();

// Bind it to Databind
gridLegalEntityEmployee.DataBind();
}
================================================== ==============

I know there is a stupid mistake I made here, but I just cant't see it. Any
suggestion or recommeded is greatly appreciated. I really appriciate you
guys help.

Thanks a lot.

Eddyyou page index changed event is mapped to the wrong handler
it should be
System.Web.UI.WebControls.DataGridPageChangedEvent Handler instead of
system.eventhandler

"Eddy Soeparmin" <esoeparmin@.clientprofiles.com> wrote in message
news:OyTwWzjSDHA.940@.TK2MSFTNGP11.phx.gbl...
> Hi,
> I'm working on a grid when the database returns ... say 100 rows. I would
> like to use the Allow Page in the grid Properties, but don't really know
how
> to code it right. I copied some code from the help, but it doesn't really
> work yet. The compiler complains on the following...
> private void InitializeComponent()
> {
> this.gridLegalEntityEmployee.SelectedIndexChanged += new
> System.EventHandler(this.gridLegalEntityEmployee_S electedIndexChanged);
> this.gridLegalEntityEmployee.PageIndexChanged += new
> System.EventHandler(this.gridLegalEntityEmployee_P ageIndexChanged );
> this.Load += new System.EventHandler(this.Page_Load);
> }
> private void gridLegalEntityEmployee_PageIndexChanged( object source,
> System.Web.UI.WebControls.DataGridPageChangedEvent Args e)
> {
> gridLegalEntityEmployee.CurrentPageIndex = e.NewPageIndex;
> gridLegalEntityEmployee.DataBind();
> }
> === Error ======
> this.gridLegalEntityEmployee_PageIndexChanged =>
> 'cpNET.WebForm1.gridLegalEntityEmployee_PageIndexC hanged(object,
> System.Web.UI.WebControls.DataGridPageChangedEvent Args)' does not match
> delegate 'void System.EventHandler(object, System.EventArgs)'
> Here is some other sniplet code
> ================================================== ==============
> private void Page_Load(object sender, System.EventArgs e)
> {
> // Put user code to initialize the page here
> gridLegalEntityEmployee.AllowPaging = true;
> gridLegalEntityEmployee.PagerStyle.Mode = PagerMode.NumericPages;
> gridLegalEntityEmployee.PagerStyle.PageButtonCount = 15;
> gridLegalEntityEmployee.PageSize = 15;
> LoadLegalEntityEmployeeList();
> if (!Page.IsPostBack)
> {
> gridLegalEntityEmployee.DataBind();
> }
> }
> private void LoadLegalEntityEmployeeList()
> {
> LegalEntityEmployee leEmployee = new LegalEntityEmployee();
> // Retrieve data from database
> gridLegalEntityEmployee.DataSource = leEmployee.SelectAll();
> // Bind it to Databind
> gridLegalEntityEmployee.DataBind();
> }
> ================================================== ==============
> I know there is a stupid mistake I made here, but I just cant't see it.
Any
> suggestion or recommeded is greatly appreciated. I really appriciate you
> guys help.
> Thanks a lot.
> Eddy

0 comments:

Post a Comment