C
Chapi
hi, i'm having problems with a datagrid paging.
it's populates fine, but when i click the paging button appears this
error:"Specified argument was out of the range of valid
values.Parameter name: index"
I paste the code here in case someone can help me.
Sub paginaNueva(ByVal sender As Object, ByVal e As
System.Web.UI.WebControls.DataGridPageChangedEventArgs)
DataGrid1.CurrentPageIndex = e.NewPageIndex
binddata()
End Sub
Sub binddata()
Dim myConnection As New
System.Data.SqlClient.SqlConnection("myconnection_string")
Dim strSQL As String = "SELECT * FROM
SISTEMAS_SIOPELMEETING_FOTOS WHERE titulo LIKE '%'+'almuerzos'+'%'"
Dim strSQL2 As String = "SELECT * FROM
SISTEMAS_SIOPELMEETING_FOTOS WHERE titulo LIKE
'%'+'presentaciones'+'%'"
Dim strSQL3 As String = "SELECT * FROM
SISTEMAS_SIOPELMEETING_FOTOS WHERE titulo LIKE '%'+'hotel'+'%'"
Dim strSQL4 As String = "SELECT * FROM
SISTEMAS_SIOPELMEETING_FOTOS WHERE titulo LIKE '%'+'estancia'+'%'"
Dim myCommand As New System.Data.SqlClient.SqlCommand(strSQL,
myConnection)
Dim myCommand2 As New
System.Data.SqlClient.SqlCommand(strSQL2, myConnection)
Dim myCommand3 As New
System.Data.SqlClient.SqlCommand(strSQL3, myConnection)
Dim myCommand4 As New
System.Data.SqlClient.SqlCommand(strSQL4, myConnection)
Dim myAdapter As New
System.Data.SqlClient.SqlDataAdapter(myCommand)
Dim myAdapter2 As New
System.Data.SqlClient.SqlDataAdapter(myCommand2)
Dim myAdapter3 As New
System.Data.SqlClient.SqlDataAdapter(myCommand3)
Dim myAdapter4 As New
System.Data.SqlClient.SqlDataAdapter(myCommand4)
Dim ds As New System.Data.DataSet()
Dim ds2 As New System.Data.DataSet()
Dim ds3 As New System.Data.DataSet()
Dim ds4 As New System.Data.DataSet()
myAdapter.Fill(ds)
myAdapter2.Fill(ds2)
myAdapter3.Fill(ds3)
myAdapter4.Fill(ds4)
DataGrid1.DataSource = ds
Datagrid2.DataSource = ds2
Datagrid3.DataSource = ds3
Datagrid4.DataSource = ds4
DataGrid1.DataBind()
Datagrid2.DataBind()
Datagrid3.DataBind()
Datagrid4.DataBind()
myConnection.Close()
End Sub
Protected Sub Page_Load(ByVal sender As Object, ByVal e As
System.EventArgs) Handles Me.Load
If Not Page.IsPostBack Then
binddata()
End If
End Sub
Thanks.
it's populates fine, but when i click the paging button appears this
error:"Specified argument was out of the range of valid
values.Parameter name: index"
I paste the code here in case someone can help me.
Sub paginaNueva(ByVal sender As Object, ByVal e As
System.Web.UI.WebControls.DataGridPageChangedEventArgs)
DataGrid1.CurrentPageIndex = e.NewPageIndex
binddata()
End Sub
Sub binddata()
Dim myConnection As New
System.Data.SqlClient.SqlConnection("myconnection_string")
Dim strSQL As String = "SELECT * FROM
SISTEMAS_SIOPELMEETING_FOTOS WHERE titulo LIKE '%'+'almuerzos'+'%'"
Dim strSQL2 As String = "SELECT * FROM
SISTEMAS_SIOPELMEETING_FOTOS WHERE titulo LIKE
'%'+'presentaciones'+'%'"
Dim strSQL3 As String = "SELECT * FROM
SISTEMAS_SIOPELMEETING_FOTOS WHERE titulo LIKE '%'+'hotel'+'%'"
Dim strSQL4 As String = "SELECT * FROM
SISTEMAS_SIOPELMEETING_FOTOS WHERE titulo LIKE '%'+'estancia'+'%'"
Dim myCommand As New System.Data.SqlClient.SqlCommand(strSQL,
myConnection)
Dim myCommand2 As New
System.Data.SqlClient.SqlCommand(strSQL2, myConnection)
Dim myCommand3 As New
System.Data.SqlClient.SqlCommand(strSQL3, myConnection)
Dim myCommand4 As New
System.Data.SqlClient.SqlCommand(strSQL4, myConnection)
Dim myAdapter As New
System.Data.SqlClient.SqlDataAdapter(myCommand)
Dim myAdapter2 As New
System.Data.SqlClient.SqlDataAdapter(myCommand2)
Dim myAdapter3 As New
System.Data.SqlClient.SqlDataAdapter(myCommand3)
Dim myAdapter4 As New
System.Data.SqlClient.SqlDataAdapter(myCommand4)
Dim ds As New System.Data.DataSet()
Dim ds2 As New System.Data.DataSet()
Dim ds3 As New System.Data.DataSet()
Dim ds4 As New System.Data.DataSet()
myAdapter.Fill(ds)
myAdapter2.Fill(ds2)
myAdapter3.Fill(ds3)
myAdapter4.Fill(ds4)
DataGrid1.DataSource = ds
Datagrid2.DataSource = ds2
Datagrid3.DataSource = ds3
Datagrid4.DataSource = ds4
DataGrid1.DataBind()
Datagrid2.DataBind()
Datagrid3.DataBind()
Datagrid4.DataBind()
myConnection.Close()
End Sub
Protected Sub Page_Load(ByVal sender As Object, ByVal e As
System.EventArgs) Handles Me.Load
If Not Page.IsPostBack Then
binddata()
End If
End Sub
Thanks.