Want to win a PS4? Go Premium and enter to win our High-Tech Treats giveaway. Enter to Win

x
?
Solved

paging

Posted on 2004-10-22
12
Medium Priority
?
230 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
Comment
Question by:rawdrib
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 8
  • 4
12 Comments
 
LVL 17

Accepted Solution

by:
AerosSaga earned 2000 total points
ID: 12384805
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
ID: 12384886
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
ID: 12384902
you missed my point I think you want pageIndexChanged, not selectedindex!

Aeros
0
Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
LVL 17

Expert Comment

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

Author Comment

by:rawdrib
ID: 12384928
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
ID: 12384964
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
ID: 12384979
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
ID: 12385066
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
ID: 12385077
OnPageIndexChanged="errorGrid_PageIndexChanged"

that should be deleted
0
 
LVL 17

Expert Comment

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

Expert Comment

by:AerosSaga
ID: 12385086
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
ID: 12385602
cheers
0

Featured Post

Ask an Anonymous Question!

Don't feel intimidated by what you don't know. Ask your question anonymously. It's easy! Learn more and upgrade.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Just a quick little trick I learned recently.  Now that I'm using jQuery with abandon in my asp.net applications, I have grown tired of the following syntax:      (CODE) I suppose it just offends my sense of decency to put inline VBScript on a…
International Data Corporation (IDC) prognosticates that before the current the year gets over disbursing on IT framework products to be sent in cloud environs will be $37.1B.
Visualize your data even better in Access queries. Given a date and a value, this lesson shows how to compare that value with the previous value, calculate the difference, and display a circle if the value is the same, an up triangle if it increased…
In this video, Percona Solutions Engineer Barrett Chambers discusses some of the basic syntax differences between MySQL and MongoDB. To learn more check out our webinar on MongoDB administration for MySQL DBA: https://www.percona.com/resources/we…
Suggested Courses

609 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