Solved

paging

Posted on 2004-10-22
226 Views
Last Modified: 2008-02-26
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??
0
Question by:rawdrib
    12 Comments
     
    LVL 17

    Accepted Solution

    by:
    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
     

    Author Comment

    by:rawdrib
    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
     
    LVL 17

    Expert Comment

    by:AerosSaga
    you missed my point I think you want pageIndexChanged, not selectedindex!

    Aeros
    0
     
    LVL 17

    Expert Comment

    by:AerosSaga
    I think your trying to use the wrong event for this
    0
     

    Author Comment

    by:rawdrib
    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
     
    LVL 17

    Expert Comment

    by:AerosSaga
    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
     
    LVL 17

    Expert Comment

    by:AerosSaga
    also, step through, and see if the event is firing and if so which line in particular the compiler is complaining about.
    0
     

    Author Comment

    by:rawdrib
    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
     
    LVL 17

    Expert Comment

    by:AerosSaga
    OnPageIndexChanged="errorGrid_PageIndexChanged"

    that should be deleted
    0
     
    LVL 17

    Expert Comment

    by:AerosSaga
    did you put that in manually?
    0
     
    LVL 17

    Expert Comment

    by:AerosSaga
    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
     

    Author Comment

    by:rawdrib
    cheers
    0

    Write Comment

    Please enter a first name

    Please enter a last name

    We will never share this with anyone.

    Featured Post

    Anonabox PRO Tor & VPN Router

    PRO is the most advanced way to fortify your privacy and online anonymity by layering the Tor network with VPN services. Use both together or separately, and without needing to download software onto your devices.

    Lots of people ask this question on how to extend the “MembershipProvider” to make use of custom authentication like using existing database or make use of some other way of authentication. Many blogs show you how to extend the membership provider c…
    Today is the age of broadband.  More and more people are going this route determined to experience the web and it’s multitude of services as quickly and painlessly as possible. Coupled with the move to broadband, people are experiencing the web via …
    Need more eyes on your posted question? Go ahead and follow the quick steps in this video to learn how to Request Attention to your question. *Log into your Experts Exchange account *Find the question you want to Request Attention for *Go to the e…
    Internet Business Fax to Email Made Easy - With eFax Corporate (http://www.enterprise.efax.com), you'll receive a dedicated online fax number, which is used the same way as a typical analog fax number. You'll receive secure faxes in your email, fr…

    856 members asked questions and received personalized solutions in the past 7 days.

    Join the community of 500,000 technology professionals and ask your questions.

    Join & Ask a Question

    Need Help in Real-Time?

    Connect with top rated Experts

    18 Experts available now in Live!

    Get 1:1 Help Now