Wrox Programmer Forums
|
VS.NET 2002/2003 Discussions about the Visual Studio.NET programming environment, the 2002 (1.0) and 2003 (1.1). ** Please don't post code questions here ** For issues specific to a particular language in .NET, please see the other forum categories.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the VS.NET 2002/2003 section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old January 6th, 2004, 10:15 PM
Authorized User
 
Join Date: Jan 2004
Posts: 18
Thanks: 0
Thanked 0 Times in 0 Posts
Default Error about paging



Hi All:
I have two problems about my Web form (Product.aspx and ProductDetail.aspx)
1. For Product.aspx, I have 2 controls (Datagrid1-dg1 and Dropdowlist1-dd1).By dd1, I retrieve data from tblMovieStyle to show Style of movie (MVS_MOVIESTYLENAME).After, I select style of movie in dd1, dg1 will show data as criteria in dd1.This point of Product.aspx is fine. But when I select page index in dg1 and then select data in dd1, it show error like this
: Invalid CurrentPageIndex value. It must be >=0 and < the PageCount

This is my coding in A.aspx

‘ ************************************************** **********
Public Class Product
    Inherits System.Web.UI.Page

#Region " Web Form Designer Generated Code "

    'This call is required by the Web Form Designer.
    <System.Diagnostics.DebuggerStepThrough()> Private Sub InitializeComponent()
        Me.OracleConnection1 = New System.Data.OracleClient.OracleConnection
        Me.OracleSelectCommand1 = New System.Data.OracleClient.OracleCommand
        Me.OracleInsertCommand1 = New System.Data.OracleClient.OracleCommand
        Me.OracleUpdateCommand1 = New System.Data.OracleClient.OracleCommand
        Me.OracleDeleteCommand1 = New System.Data.OracleClient.OracleCommand
        Me.OracleDataAdapter1 = New System.Data.OracleClient.OracleDataAdapter
        Me.DataSetProduct1 = New WebApplication1.DataSetProduct
        Me.OracleSelectCommand2 = New System.Data.OracleClient.OracleCommand
        Me.OracleInsertCommand2 = New System.Data.OracleClient.OracleCommand
        Me.OracleUpdateCommand2 = New System.Data.OracleClient.OracleCommand
        Me.OracleDeleteCommand2 = New System.Data.OracleClient.OracleCommand
        Me.OracleDataAdapter2 = New System.Data.OracleClient.OracleDataAdapter
        Me.DataSetMovieStyle1 = New WebApplication1.DataSetMovieStyle
        CType(Me.DataSetProduct1, System.ComponentModel.ISupportInitialize).BeginIni t()
        CType(Me.DataSetMovieStyle1, System.ComponentModel.ISupportInitialize).BeginIni t()
        '
        'OracleConnection1
        '
        Me.OracleConnection1.ConnectionString = "user id=scott;integrated security=False;data source=orcl;password=tiger"
        '
        'OracleSelectCommand1
        '
        Me.OracleSelectCommand1.CommandText = "SELECT * FROM tblproduct "
        Me.OracleSelectCommand1.Connection = Me.OracleConnection1
        '
        'OracleDataAdapter1
        '
        Me.OracleDataAdapter1.DeleteCommand = Me.OracleDeleteCommand1
        Me.OracleDataAdapter1.InsertCommand = Me.OracleInsertCommand1
        Me.OracleDataAdapter1.SelectCommand = Me.OracleSelectCommand1
        Me.OracleDataAdapter1.UpdateCommand = Me.OracleUpdateCommand1
        '
        'DataSetProduct1
        '
        Me.DataSetProduct1.DataSetName = "DataSetProduct"
        Me.DataSetProduct1.Locale = New System.Globalization.CultureInfo("en-US")
        '
        'DataSetMovieStyle1
        '
        Me.DataSetMovieStyle1.DataSetName = "DataSetMovieStyle"
        Me.DataSetMovieStyle1.Locale = New System.Globalization.CultureInfo("en-US")
        CType(Me.DataSetProduct1, System.ComponentModel.ISupportInitialize).EndInit( )
        CType(Me.DataSetMovieStyle1, System.ComponentModel.ISupportInitialize).EndInit( )

    End Sub
    Protected WithEvents OracleConnection1 As System.Data.OracleClient.OracleConnection
    Protected WithEvents OracleSelectCommand1 As System.Data.OracleClient.OracleCommand
    Protected WithEvents OracleInsertCommand1 As System.Data.OracleClient.OracleCommand
    Protected WithEvents OracleUpdateCommand1 As System.Data.OracleClient.OracleCommand
    Protected WithEvents OracleDeleteCommand1 As System.Data.OracleClient.OracleCommand
    Protected WithEvents OracleDataAdapter1 As System.Data.OracleClient.OracleDataAdapter
    Protected WithEvents DataGrid1 As System.Web.UI.WebControls.DataGrid
    Protected WithEvents DataSetProduct1 As WebApplication1.DataSetProduct
    Protected WithEvents DropDownList1 As System.Web.UI.WebControls.DropDownList
    Protected WithEvents OracleSelectCommand2 As System.Data.OracleClient.OracleCommand
    Protected WithEvents OracleInsertCommand2 As System.Data.OracleClient.OracleCommand
    Protected WithEvents OracleUpdateCommand2 As System.Data.OracleClient.OracleCommand
    Protected WithEvents OracleDeleteCommand2 As System.Data.OracleClient.OracleCommand
    Protected WithEvents OracleDataAdapter2 As System.Data.OracleClient.OracleDataAdapter
    Protected WithEvents DataSetMovieStyle1 As WebApplication1.DataSetMovieStyle

    'NOTE: The following placeholder declaration is required by the Web Form Designer.
    'Do not delete or move it.
    Private designerPlaceholderDeclaration As System.Object

    Private Sub Page_Init(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Init
        'CODEGEN: This method call is required by the Web Form Designer
        'Do not modify it using the code editor.
        InitializeComponent()
    End Sub

#End Region

    Private Sub Page_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
        'Put user code to initialize the page here
        If Not Page.IsPostBack Then
            OracleDataAdapter1.Fill(DataSetProduct1)
            DataGrid1.DataSource = DataSetProduct1
            DataGrid1.DataBind()
            ' - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
            Dim cmdMovieStyle As New OracleClient.OracleCommand _
                ("SELECT MVS_MOVIESTYLENAME FROM tblMovieStyle", OracleConnection1)
            Dim drMovieStyle As OracleClient.OracleDataReader
            OracleConnection1.Open()
            drMovieStyle = cmdMovieStyle.ExecuteReader()
            DropDownList1.DataSource = drMovieStyle
            DropDownList1.DataTextField = "MVS_MOVIESTYLENAME"
            DropDownList1.DataBind()
            drMovieStyle.Close()
            OracleConnection1.Close()
            ' - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
            DropDownList1.Items.Add("[All]")
            DropDownList1.SelectedIndex = DropDownList1.Items.Count - 1

        End If
        DataGrid1.Columns(0).FooterText = DataGrid1.PageCount & " Pages Found"

    End Sub



    Private Sub DataGrid1_ItemCommand(ByVal source As Object, ByVal e As System.Web.UI.WebControls.DataGridCommandEventArgs ) Handles DataGrid1.ItemCommand
        If e.Item.ItemIndex > -1 Then
            Dim strProdID As String
            DataGrid1.SelectedIndex = e.Item.ItemIndex
            strProdID = (DataGrid1.Items(DataGrid1.SelectedIndex).Cells(2) .Text)
            Response.Redirect("Productdetail.aspx?pcp=" & strProdID)
        End If
    End Sub

    Private Sub DataGrid1_PageIndexChanged(ByVal source As Object, ByVal e As System.Web.UI.WebControls.DataGridPageChangedEvent Args) Handles DataGrid1.PageIndexChanged
        Dim strMovieStyle As String = Trim(DropDownList1.SelectedItem.Value)
        DataGrid1.CurrentPageIndex = e.NewPageIndex
        OracleDataAdapter1.Fill(DataSetProduct1)
        If strMovieStyle = "[All]" Then
            DataGrid1.DataSource = DataSetProduct1
        Else
            Dim dvProduct As New DataView(DataSetProduct1.Tables(0)) '"TblProduct"
            dvProduct.RowFilter = "prd_styleid='" & strMovieStyle & "'"
            DataGrid1.DataSource = dvProduct
        End If
        DataGrid1.DataBind()

    End Sub


    Private Sub DropDownList1_SelectedIndexChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles DropDownList1.SelectedIndexChanged

        Dim strMovieStyle As String = Trim(DropDownList1.SelectedItem.Value)
        OracleDataAdapter1.Fill(DataSetProduct1)
        If strMovieStyle = "[All]" Then
            DataGrid1.DataSource = DataSetProduct1
        Else
            Dim dvProduct As New DataView(DataSetProduct1.Tables(0)) '"TblProduct"
            dvProduct.RowFilter = "prd_styleid='" & strMovieStyle & "'"
            DataGrid1.DataSource = dvProduct
        End If
        Reset()
        DataGrid1.DataBind()
    End Sub

End Class

‘ ************************************************** **********
2. When I select data in dg1, I’d like to send data to ProductDetail.aspx as shown in datagrid1_Itemcommand. It‘s fine for send data to ProductDetail.aspx. But I’d like to use the selected data to be parameter in this commandText

Me.OracleSelectCommand1.CommandText = "SELECT * FROM tblproduct WHERE prd_Productid =’" & strProId & “’”

For show more details of the selected data from Product.aspx in ProductDetail.aspx. But it shows the error

‘ ************************************************** ************

How should I solve these questions?

Thanks in advance

Blueman137


 
Old January 7th, 2004, 11:57 AM
planoie's Avatar
Friend of Wrox
 
Join Date: Aug 2003
Posts: 5,407
Thanks: 0
Thanked 16 Times in 16 Posts
Default

This is a duplicate of this thread.
Please don't cross post unless you can't get an answer from your first attempt.

Peter
------------------------------------------------------
Work smarter, not harder.





Similar Threads
Thread Thread Starter Forum Replies Last Post
Paging Problem Revisited - Index Error rstelma General .NET 9 February 3rd, 2006 07:10 PM
Paging Index Error rstelma ASP.NET 1.0 and 1.1 Professional 2 February 1st, 2006 02:41 PM
datagrid paging error RPG SEARCH ASP.NET 1.0 and 1.1 Basics 1 November 9th, 2004 08:29 AM
Getting error w/Paging through recordset Calibus Classic ASP Databases 3 September 2nd, 2004 06:41 PM
Error About Paging Blueman137 ASP.NET 1.0 and 1.1 Basics 2 January 9th, 2004 01:16 AM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.