datagrid paging

Discussion in 'ASP .Net Datagrid Control' started by dibusi, May 16, 2005.

  1. dibusi

    dibusi Guest

    i have a trouble with datagrid with web matrix.It doesn't browse the records
    when i click on the navigation buttons of the datagrid.it displays only the
    first records.
    thankyou for the help.
    Sub Page_Load(Sender As Object, E As EventArgs)

    If Not Page.IsPostBack Then

    ' Databind the data grid on the first request only
    ' (on postback, rebind only in paging command)
    DATAGRID1.VirtualItemCount=2000
    BindGrid()

    End If

    End Sub

    Sub DataGrid_Page(Sender As Object, e As DataGridPageChangedEventArgs)
    BindGrid()
    DataGrid1.CurrentPageIndex = e.NewPageIndex
    End Sub
    sub BindGrid()

    ' TODO: update the ConnectionString value for your application
    ' DataGrid1.DatakeyField="AMAT_NUME_TIERS"
    Dim ConnectionString AS String =
    "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=e:\assmat\bdamat2000.MDB"
    'Dim ConnectionString As String =
    "server=(local);database=pubs;trusted_connection=true"
    Dim CommandText As String = "select amat_nume_tiers,amat_nom_1 as nom,
    AMAT_PRENOM as prénom from tamat"
    DIM commande AS STRING
    dim valeur as String=request.querystring("nom")
    IF valeur<>"" then
    commande =" where amat_nom_commune like '" & valeur & "%'"
    end if
    CommandText=CommandText & commande & " order by amat_nom_1"
    Dim myConnection As New OleDbConnection
    myConnection.ConnectionString=ConnectionString
    myConnection.Open()
    Dim myCommand As New OleDbCommand(CommandText, myConnection)
    DataGrid1.DataSource =
    myCommand.ExecuteReader(CommandBehavior.CloseConnection)
    DataGrid1.DataBind()
    End Sub
    dibusi, May 16, 2005
    #1
    1. Advertising

  2. dibusi

    kchalla Guest

    Hi dibusi,

    you try with the following code.

    Sub DataGrid_Page(Sender As Object, e As DataGridPageChangedEventArgs)
    DataGrid1.CurrentPageIndex = e.NewPageIndex
    BindGrid()
    End Sub

    regards,
    kchalla

    "dibusi" wrote:

    > i have a trouble with datagrid with web matrix.It doesn't browse the records
    > when i click on the navigation buttons of the datagrid.it displays only the
    > first records.
    > thankyou for the help.
    > Sub Page_Load(Sender As Object, E As EventArgs)
    >
    > If Not Page.IsPostBack Then
    >
    > ' Databind the data grid on the first request only
    > ' (on postback, rebind only in paging command)
    > DATAGRID1.VirtualItemCount=2000
    > BindGrid()
    >
    > End If
    >
    > End Sub
    >
    > Sub DataGrid_Page(Sender As Object, e As DataGridPageChangedEventArgs)
    > BindGrid()
    > DataGrid1.CurrentPageIndex = e.NewPageIndex
    > End Sub
    > sub BindGrid()
    >
    > ' TODO: update the ConnectionString value for your application
    > ' DataGrid1.DatakeyField="AMAT_NUME_TIERS"
    > Dim ConnectionString AS String =
    > "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=e:\assmat\bdamat2000.MDB"
    > 'Dim ConnectionString As String =
    > "server=(local);database=pubs;trusted_connection=true"
    > Dim CommandText As String = "select amat_nume_tiers,amat_nom_1 as nom,
    > AMAT_PRENOM as prénom from tamat"
    > DIM commande AS STRING
    > dim valeur as String=request.querystring("nom")
    > IF valeur<>"" then
    > commande =" where amat_nom_commune like '" & valeur & "%'"
    > end if
    > CommandText=CommandText & commande & " order by amat_nom_1"
    > Dim myConnection As New OleDbConnection
    > myConnection.ConnectionString=ConnectionString
    > myConnection.Open()
    > Dim myCommand As New OleDbCommand(CommandText, myConnection)
    > DataGrid1.DataSource =
    > myCommand.ExecuteReader(CommandBehavior.CloseConnection)
    > DataGrid1.DataBind()
    > End Sub
    >
    >
    >
    kchalla, May 16, 2005
    #2
    1. Advertising

  3. dibusi

    dibusi Guest

    hi kchalla

    i tried to put the code
    > Sub DataGrid_Page(Sender As Object, e As DataGridPageChangedEventArgs)
    > DataGrid1.CurrentPageIndex = e.NewPageIndex
    > BindGrid()
    > End Sub

    it doesn't work eiher

    yours sincerely

    "kchalla" <> a écrit dans le message de news:
    ...
    > Hi dibusi,
    >
    > you try with the following code.
    >
    > Sub DataGrid_Page(Sender As Object, e As DataGridPageChangedEventArgs)
    > DataGrid1.CurrentPageIndex = e.NewPageIndex
    > BindGrid()
    > End Sub
    >
    > regards,
    > kchalla
    >
    > "dibusi" wrote:
    >
    >> i have a trouble with datagrid with web matrix.It doesn't browse the
    >> records
    >> when i click on the navigation buttons of the datagrid.it displays only
    >> the
    >> first records.
    >> thankyou for the help.
    >> Sub Page_Load(Sender As Object, E As EventArgs)
    >>
    >> If Not Page.IsPostBack Then
    >>
    >> ' Databind the data grid on the first request only
    >> ' (on postback, rebind only in paging command)
    >> DATAGRID1.VirtualItemCount=2000
    >> BindGrid()
    >>
    >> End If
    >>
    >> End Sub
    >>
    >> Sub DataGrid_Page(Sender As Object, e As DataGridPageChangedEventArgs)
    >> BindGrid()
    >> DataGrid1.CurrentPageIndex = e.NewPageIndex
    >> End Sub
    >> sub BindGrid()
    >>
    >> ' TODO: update the ConnectionString value for your application
    >> ' DataGrid1.DatakeyField="AMAT_NUME_TIERS"
    >> Dim ConnectionString AS String =
    >> "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=e:\assmat\bdamat2000.MDB"
    >> 'Dim ConnectionString As String =
    >> "server=(local);database=pubs;trusted_connection=true"
    >> Dim CommandText As String = "select amat_nume_tiers,amat_nom_1 as
    >> nom,
    >> AMAT_PRENOM as prénom from tamat"
    >> DIM commande AS STRING
    >> dim valeur as String=request.querystring("nom")
    >> IF valeur<>"" then
    >> commande =" where amat_nom_commune like '" & valeur & "%'"
    >> end if
    >> CommandText=CommandText & commande & " order by amat_nom_1"
    >> Dim myConnection As New OleDbConnection
    >> myConnection.ConnectionString=ConnectionString
    >> myConnection.Open()
    >> Dim myCommand As New OleDbCommand(CommandText, myConnection)
    >> DataGrid1.DataSource =
    >> myCommand.ExecuteReader(CommandBehavior.CloseConnection)
    >> DataGrid1.DataBind()
    >> End Sub
    >>
    >>
    >>
    dibusi, May 21, 2005
    #3
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. =?Utf-8?B?UGF0cmljay5PLklnZQ==?=

    DataSet paging vs Datareader paging

    =?Utf-8?B?UGF0cmljay5PLklnZQ==?=, Oct 8, 2004, in forum: ASP .Net
    Replies:
    1
    Views:
    10,648
    Scott Allen
    Oct 8, 2004
  2. Roger
    Replies:
    0
    Views:
    948
    Roger
    Dec 28, 2004
  3. wh1974
    Replies:
    0
    Views:
    2,413
    wh1974
    Jan 12, 2005
  4. Red
    Replies:
    1
    Views:
    699
  5. Green Start Button

    DataGrid.Items.Count and DataGrid Paging...

    Green Start Button, Aug 4, 2005, in forum: ASP .Net
    Replies:
    2
    Views:
    5,777
    agravar
    Aug 2, 2006
Loading...

Share This Page