Trying to use the FAQ " Sorting and paging in the GridView control when not using data source controls "Sorting and paging in the GridView control when not using..."


and I am not getting the results I had hoped for.  I keep getting a "Compiler Error Message: CS0123: No overload for 'AdhocJobGridView_PageIndexChanged' matches delegate 'System.EventHandler'".
 
Here is my event handling...
protected void AdhocJobGridView_PageIndexChanged(object sender, GridViewPageEventArgs e){
try
{
AdhocJobGridView.DataSource = wsBaseInfoArray;
AdhocJobGridView.PageIndex = e.NewPageIndex;
AdhocJobGridView.DataBind();
}
catch (Exception ex)
{
throw ex;
}
 
Here is my aspx...
asp:GridView ID="AdhocJobGridView" runat="server"
AutoGenerateColumns="false"
AlternatingRowStyle-BackColor="LightYellow"
SelectedRowStyle-BackColor="LightGray"
AutoGenerateSelectButton="true" DataKeyNames="jobGroupID"
HorizontalAlign="NotSet"
AllowPaging="false"
PageSize="15"
onpageindexchanged="AdhocJobGridView_PageIndexChanged"
Font-Names="calibri"
Font-Size="medium">
pagersettings mode="Numeric"
position="bottom"
pagebuttoncount="10"/>
pagerstyle backcolor="Lightgrey"/>
Columns>
asp:BoundField HeaderText="Plan/Group/Job" DataField="jobGroupName" ReadOnly="true" />
asp:BoundField HeaderText="Job" DataField="code" />
asp:BoundField HeaderText="Description" DataField="description" />
Columns>
SelectedRowStyle BorderColor="Red">SelectedRowStyle>
asp:GridView>
Any ideas as to what I am missing?
Thanks
 
P.S. I dont need the sorting so that part was purposefully left out!
0
mathiasX
3/16/2009 9:59:57 PM
📁 asp.net.presentation-controls
📃 72751 articles.
⭐ 3 followers.

💬 4 Replies
👁️‍🗨️ 4882 Views



mathiasX:

and I am not getting the results I had hoped for.  I keep getting a "Compiler Error Message: CS0123: No overload for 'AdhocJobGridView_PageIndexChanged' matches delegate 'System.EventHandler'".

 

Here is my event handling...

protected void AdhocJobGridView_PageIndexChanged(object sender, GridViewPageEventArgs e)

{

try

{

AdhocJobGridView.DataSource = wsBaseInfoArray;

AdhocJobGridView.PageIndex = e.NewPageIndex;

AdhocJobGridView.DataBind();

}

catch (Exception ex)

{

throw ex;

}

 
The PageIndexChanged event the signature is (object sender, EventArgs e) NOT (object sender, GridViewPageEventArgs e) .

The signature you are using matches with PageIndexChanging event.

http://ryanolshan.com/articles/c-gridview-sorting-paging-w-o-a-datasourcecontrol-datasource/

Regards,Vinz

"Code, Beer and Music" that's my way of being a programmer!

How to get your Forum Question Answered | Blog | CodeASP.NET
0
vinz
3/17/2009 1:13:16 AM

I am trying to use the code that is represented in the FAQ on this forum as follows...
http://forums.asp.net/t/1352646.aspx#_1.1_Sorting_and 
As you can see from that example I they are able to use the GridViewPageEventArgs e object. I am basically trying to imlement the same code but without the sorting portion.  If I use the EventArgs e object I wont have access to the e.NewPageIndex property, which I need per the example.  Unless there is another way of extracting the e.NewPageIndex property that I am overlooking?
0
mathiasX
3/17/2009 4:37:55 AM

mathiasX:

I am trying to use the code that is represented in the FAQ on this forum as follows...

http://forums.asp.net/t/1352646.aspx#_1.1_Sorting_and 

As you can see from that example I they are able to use the GridViewPageEventArgs e object. I am basically trying to imlement the same code but without the sorting portion.  If I use the EventArgs e object I wont have access to the e.NewPageIndex property, which I need per the example.  Unless there is another way of extracting the e.NewPageIndex property that I am overlooking?

 
The sample codes in the link uses PageIndexChanging and in your codes you are using PageIndexChanged event which is incompatible with the signatures you used.. Please note that the two events are a bit different.. So you need to use PageIndexChanging event instead..

Regards,Vinz

"Code, Beer and Music" that's my way of being a programmer!

How to get your Forum Question Answered | Blog | CodeASP.NET
0
vinz
3/17/2009 4:52:25 AM

Nice catch!  Sometimes I can't see the forest for all these damn trees in the way!  Thanks vinz!
0
mathiasX
3/17/2009 6:24:02 AM
Reply: