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