Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
CODE PROJECT For Those Who Code
  • Home
  • Articles
  • FAQ
Community
  1. Home
  2. Web Development
  3. Problems with query pagination in asp.net

Problems with query pagination in asp.net

Scheduled Pinned Locked Moved Web Development
databasehelpcsharpasp-netcom
2 Posts 2 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • H Offline
    H Offline
    haggenx
    wrote on last edited by
    #1

    Hi! I have a problem, i am programming a datagrid in asp.net under webmatrix, only is a connection to access database and show this query in a datagrid, every very good exception for the query pagination. How i can allow what, if the user press a number of page from query, then the asp change the query result to the number page?, attach the code because not work this section, thanks very mucho for you help. --------------------------------------------------------------------------------------------------------- Private connectionString As String = "Provider=Microsoft.Jet.OLEDB.4.0; Ole DB Services=-4; Data Source=C:\lo que se va a estar respaldando\mio\my_access_db.mdb" Private dbConnection As System.Data.IDbConnection = New System.Data.OleDb.OleDbConnection(connectionString) Private dbCommand As System.Data.IDbCommand = New System.Data.OleDb.OleDbCommand private dataAdapter As System.Data.IDbDataAdapter = New System.Data.OleDb.OleDbDataAdapter private dataSet As System.Data.DataSet = New System.Data.DataSet '///////////////////////////////////////// Sub cmdQuery_Click(sender As Object, e As EventArgs) If Len(Trim(txtSQLQUery.Text)) > 0 Then SQLProcesss(Trim(txtSQLQUery.Text)) Else MsgBox("No SQL Query string ingresed!", vbCritical, "Error") End If End Sub '///////////////////////////////////////// Sub SQLProcesss(SQLCommand) dbCommand.CommandText = SQLCommand dbCommand.Connection = dbConnection dataAdapter.SelectCommand = dbCommand dataAdapter.Fill(dataSet) dgData.DataSource = dataSet.Tables(0) dgData.DataBind() MsgBox(Str(dataSet.Tables(0).Rows.Count) + " rows found!", vbInformation, "Query") End Sub '///////////////////////////////////////// Sub cmdClear_Click(sender As Object, e As EventArgs) txtSQLQuery.Text = "" End Sub Sub dgData_PageIndexChanged(ByVal source As Object, ByVal e As System.Web.UI.WebControls.DataGridPageChangedEventArgs) 'This section not change the query results to the number page dgData.PageIndexChanged = new DataGridPageChangedEventHandler(this.dgrdDepartments_PageIndexChanged) End Sub

    Cuando salga el sol, no estare aqui...

    V 1 Reply Last reply
    0
    • H haggenx

      Hi! I have a problem, i am programming a datagrid in asp.net under webmatrix, only is a connection to access database and show this query in a datagrid, every very good exception for the query pagination. How i can allow what, if the user press a number of page from query, then the asp change the query result to the number page?, attach the code because not work this section, thanks very mucho for you help. --------------------------------------------------------------------------------------------------------- Private connectionString As String = "Provider=Microsoft.Jet.OLEDB.4.0; Ole DB Services=-4; Data Source=C:\lo que se va a estar respaldando\mio\my_access_db.mdb" Private dbConnection As System.Data.IDbConnection = New System.Data.OleDb.OleDbConnection(connectionString) Private dbCommand As System.Data.IDbCommand = New System.Data.OleDb.OleDbCommand private dataAdapter As System.Data.IDbDataAdapter = New System.Data.OleDb.OleDbDataAdapter private dataSet As System.Data.DataSet = New System.Data.DataSet '///////////////////////////////////////// Sub cmdQuery_Click(sender As Object, e As EventArgs) If Len(Trim(txtSQLQUery.Text)) > 0 Then SQLProcesss(Trim(txtSQLQUery.Text)) Else MsgBox("No SQL Query string ingresed!", vbCritical, "Error") End If End Sub '///////////////////////////////////////// Sub SQLProcesss(SQLCommand) dbCommand.CommandText = SQLCommand dbCommand.Connection = dbConnection dataAdapter.SelectCommand = dbCommand dataAdapter.Fill(dataSet) dgData.DataSource = dataSet.Tables(0) dgData.DataBind() MsgBox(Str(dataSet.Tables(0).Rows.Count) + " rows found!", vbInformation, "Query") End Sub '///////////////////////////////////////// Sub cmdClear_Click(sender As Object, e As EventArgs) txtSQLQuery.Text = "" End Sub Sub dgData_PageIndexChanged(ByVal source As Object, ByVal e As System.Web.UI.WebControls.DataGridPageChangedEventArgs) 'This section not change the query results to the number page dgData.PageIndexChanged = new DataGridPageChangedEventHandler(this.dgrdDepartments_PageIndexChanged) End Sub

      Cuando salga el sol, no estare aqui...

      V Offline
      V Offline
      Vasudevan Deepak Kumar
      wrote on last edited by
      #2

      Check for IsPostBack before databinding again.

      Vasudevan Deepak Kumar Personal Homepage Tech Gossips

      1 Reply Last reply
      0
      Reply
      • Reply as topic
      Log in to reply
      • Oldest to Newest
      • Newest to Oldest
      • Most Votes


      • Login

      • Don't have an account? Register

      • Login or register to search.
      • First post
        Last post
      0
      • Categories
      • Recent
      • Tags
      • Popular
      • World
      • Users
      • Groups