1

Afternoon All,

I have a simple gridview with list items items that have been uploaded to file. I had an issue with paging on my gridview. As i selected page two the webpage would fail.

After looking aroud on the internet, i have seem that i need to add a PageIndexChanging' event to my gridview. I have tried to complete this via the following code but have a issue with e.NewPageIndex, this has an error that states... 'NewPageIndex' is not a member of 'System.Event.Args'.

Here is the vb for the PageIndexChanging event...

Protected Sub UploadedFiles_PageIndexChanging(ByVal sender As Object, ByVal e As System.EventArgs) Handles UploadedFiles_PageIndexChanging
    UploadedFiles.PageIndex = e.NewPageIndex
    UploadedFiles.DataBind()
End Sub

And here is my gridview code...

       <asp:GridView  ID="UploadedFiles" 
           DataSource="<%# GetUploadList() %>" 
           runat="server" 
           CssClass="mGrid" 
           Width="300px"   
           PagerStyle-CssClass="pgr" 
           AlternatingRowStyle-CssClass="alt"  
           CellPadding="4" 
           ForeColor="#333333" 
           AllowPaging="True" 
           PageSize="2" 
           AllowSorting="True" > 
        <AlternatingRowStyle CssClass="alt" />
        <PagerStyle CssClass="pgr" />
       </asp:GridView>  

Many thanks in advance for an help.

Regards Betty

Amarnath Balasubramanian
  • 9,300
  • 8
  • 34
  • 62
Betty
  • 621
  • 1
  • 12
  • 24

2 Answers2

1

Wrong signature - try this:

Protected Sub UploadedFiles_PageIndexChanging(ByVal sender As Object, ByVal e As GridViewPageEventArgs) Handles UploadedFiles_PageIndexChanging
FiveTools
  • 5,970
  • 15
  • 62
  • 84
  • I have added the'GridViewPageEvents' part to my code. However i now have an error stating 'Identifier Expected' at the end on the first line of code. I was that the ' Handles UploadedFiles_PageIndexChanging.' didnt require anything but this insists on a (.) and then more additional code? – Betty May 17 '12 at 13:36
  • Usually that means you have a misplaced colon or bracket. I added 'Protected Sub' to the signature in case there is misunderstanding on how it should start. – FiveTools May 17 '12 at 13:41
  • just what i thought. I have solved this by removing the line of code and then adding this back in again with intelisence. Many thanks for your help. This works a treat now. – Betty May 17 '12 at 13:47
0

Take a look at the PageIndexChanging event on MSDN, notice that it doesn't take an EventArgs, it takes a GridViewPageEventArgs. GridViewPageEventArgs does have a NewPageIndex property.

Greg B
  • 14,597
  • 18
  • 87
  • 141