paging

i had the paging all set up, and worked correctly....until i put in an event handler for a 'details' button click for a row in my datagrid.  the datagrid tag is as follows:

<asp:datagrid id="errorGrid" style="Z-INDEX: 101; LEFT: 16px; POSITION: absolute; TOP: 208px"
                        Runat="server" PagerStyle-Mode="NumericPages" PagerStyle-PageButtonCount="10"  OnPageIndexChanged="errorGrid_SelectedIndexChanged"
                        OnSortCommand="SortEventHandler" OnItemCommand="Details_onClick" Height="217px" Width="752px"
                        AllowPaging="True" AllowSorting="True" BackColor="White">


and i have these two event handlers in my VB code-behind:

   Public Sub errorGrid_SelectedIndexChanged(ByVal sender As System.Object, ByVal e As DataGridPageChangedEventArgs)
        errorGrid.CurrentPageIndex = e.NewPageIndex
        Dim strSQL As String
        strSQL = "SELECT E.ErrorID, E.CreateDate, ISNULL(E.PageURL,'')+ISNULL(E.ProcessName,'') as ProcessOrPage, E.ErrorNumber as Error#, ES.ErrorDescription as Status, LEFT(E.ErrorText,40) as ErrorText FROM (Error E join ErrorStatus ES on E.ErrorStatusID = ES.ErrorStatusID)"
        PageLoadBindData(strSQL)
    End Sub


   Public Sub Details_onClick(ByVal sender As System.Object, ByVal e As DataGridCommandEventArgs)
        Dim errorID As Integer = Convert.ToInt32(e.Item.Cells(1).Text)
        Response.Redirect("ErrorDetails.aspx?ErrorID=" & Server.UrlEncode(errorID))
    End Sub



while debugging, i have found that when clicking on a page number goes through the Details_onClick routine instead of the errorGrid_SelectedIndexChanged routine.  so when running the app and clicking on a page link brings up the following error:


>Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code.
>
>Exception Details: System.ArgumentOutOfRangeException: Specified argument was out of the range of valid values. Parameter name: index
>
>Source Error:
>
>
>Line 105:
>Line 106:    Public Sub Details_onClick(ByVal sender As System.Object, ByVal e As DataGridCommandEventArgs)
>Line 107:        Dim errorID As Integer = Convert.ToInt32(e.Item.Cells(1).Text)
>Line 108:        Response.Redirect("ErrorDetails.aspx?ErrorID=" & Server.UrlEncode(errorID))
>Line 109:    End Sub

>
>Source File: D:\Files\DOTNET\wwwroot\WebApplication1\ErrorReport.aspx.vb    Line: 107


any idea what is going wrong??
rawdribAsked:
Who is Participating?

[Webinar] Streamline your web hosting managementRegister Today

x
 
AerosSagaConnect With a Mentor Commented:
I think you may be using the wrong event:

 Private Sub Products_PageIndexChanged(ByVal source As Object, ByVal e As System.Web.UI.WebControls.DataGridPageChangedEventArgs) Handles Products.PageIndexChanged
        Products.CurrentPageIndex = e.NewPageIndex
        LoadProductData()
    End Sub

Aeros
0
 
rawdribAuthor Commented:
changed the format of the subroutine to:

 Private Sub errorGrid_SelectedIndexChanged(ByVal sender As Object, ByVal e As System.Web.UI.WebControls.DataGridPageChangedEventArgs) Handles errorGrid.PageIndexChanged
        errorGrid.CurrentPageIndex = e.NewPageIndex
        Dim strSQL As String
        strSQL = "SELECT E.ErrorID, E.CreateDate, ISNULL(E.PageURL,'')+ISNULL(E.ProcessName,'') as ProcessOrPage, E.ErrorNumber as Error#, ES.ErrorDescription as Status, LEFT(E.ErrorText,40) as ErrorText FROM (Error E join ErrorStatus ES on E.ErrorStatusID = ES.ErrorStatusID)"
        PageLoadBindData(strSQL)
    End Sub


when attempting to run, it doesn't even load the first page now, but spits out this 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: BC30390: 'WebApplication1.ErrorReport.Private Sub errorGrid_SelectedIndexChanged(sender As Object, e As System.Web.UI.WebControls.DataGridPageChangedEventArgs)' is not accessible in this context because it is 'Private'.



when putting it back as 'public', it does the same error when attempting to page
0
 
AerosSagaCommented:
you missed my point I think you want pageIndexChanged, not selectedindex!

Aeros
0
Never miss a deadline with monday.com

The revolutionary project management tool is here!   Plan visually with a single glance and make sure your projects get done.

 
AerosSagaCommented:
I think your trying to use the wrong event for this
0
 
rawdribAuthor Commented:
ahh, gotcha, but changed that and still get the same errors

Public Sub errorGrid_PageIndexChanged(ByVal sender As Object, ByVal e As System.Web.UI.WebControls.DataGridPageChangedEventArgs) Handles errorGrid.PageIndexChanged
        errorGrid.CurrentPageIndex = e.NewPageIndex
        Dim strSQL As String
        strSQL = "SELECT E.ErrorID, E.CreateDate, ISNULL(E.PageURL,'')+ISNULL(E.ProcessName,'') as ProcessOrPage, E.ErrorNumber as Error#, ES.ErrorDescription as Status, LEFT(E.ErrorText,40) as ErrorText FROM (Error E join ErrorStatus ES on E.ErrorStatusID = ES.ErrorStatusID)"
        PageLoadBindData(strSQL)
    End Sub
0
 
AerosSagaCommented:
ok sounds like its missing its protected with events decleration at the top of your codebehind.  Try this, copy that event into notepad, then in the top of the codebehind from the drop down lists select your datagrid and the pageindexchanged event.  It should recreate it for you.  Then paste your routine in the newly created event.
0
 
AerosSagaCommented:
also, step through, and see if the event is firing and if so which line in particular the compiler is complaining about.
0
 
rawdribAuthor Commented:
i did the thing with the drop down list, it recreated it, i pasted the code inside, but it won't compile because it is stating:

Compiler Error Message: BC30390: 'WebApplication1.ErrorReport.Private Sub errorGrid_PageIndexChanged(source As Object, e As System.Web.UI.WebControls.DataGridPageChangedEventArgs)' is not accessible in this context because it is 'Private'.



the line of code it shows in red is the asp:datagrid tag which i have as follows:

<asp:datagrid id="errorGrid" style="Z-INDEX: 101; LEFT: 16px; POSITION: absolute; TOP: 208px"
                        Runat="server" PagerStyle-Mode="NumericPages" PagerStyle-PageButtonCount="10"  OnPageIndexChanged="errorGrid_PageIndexChanged"
                        OnSortCommand="SortEventHandler" OnItemCommand="Details_onClick" Height="217px" Width="752px"
                        AllowPaging="True" AllowSorting="True" BackColor="White">


am i missing some declaration or statement in this that you know of??
0
 
AerosSagaCommented:
OnPageIndexChanged="errorGrid_PageIndexChanged"

that should be deleted
0
 
AerosSagaCommented:
did you put that in manually?
0
 
AerosSagaCommented:
if your using the prebuilt events, you don't need to specify them like that.  Its beer:30 here so I'll check back later.

Aeros
0
 
rawdribAuthor Commented:
cheers
0
All Courses

From novice to tech pro — start learning today.