Results 1 to 3 of 3

Thread: Datagrid Paging Question

  1. #1

    Thread Starter
    Hyperactive Member kleptos's Avatar
    Join Date
    Aug 2001
    Location
    The Dark Carnival
    Posts
    346

    Datagrid Paging Question

    If i have a datagrid and want to implement paging, i can do it and it shows correctly on the rendered web page. But if i click on the numbers to go to the next page, i get a page not found, i am assuming i have to add the code to go to the next set of records, and ideas how to do that? In C#?
    ..::[kleptos]::..
    • Database Administrator (MSSQL 2000)
    • Application Developer (C#)
    • Web Developer (ASP.NET)


  2. #2
    Banished Cander's Avatar
    Join Date
    Dec 2000
    Location
    Why do you care?
    Posts
    6,913
    example..in VB..sorry but ahould be simple to convert to c#

    Code:
    <asp:DataGrid id="gridCorpList" runat="server" AllowPaging="True" OnPageIndexChanged="gridCorpList_Page" Width="100%" PageSize="5" ShowHeader="False" GridLines="None">
            <PagerStyle mode="NumericPages"></PagerStyle>
        </asp:DataGrid>
    Code:
    Sub gridCorpList_Page(source As Object, e As DataGridPageChangedEventArgs)
            gridCorpList.CurrentPageIndex = e.NewPageIndex
            strSQL= "Select Corp_Name FROM Corporations Where id <> 1 ORDER BY Corp_Name"
            myConn = New OleDbConnection (strConnString)
            ' Populate the Dataset from the SQL statement
            ' Run the Sql statement and get the Data into the DataAdapter
            myCommand = New OleDbDataAdapter(strSQL, myConn)
            ' Fill the DataSet and name the table
            myCommand.Fill(myDS, "Corp")
            myConn.Close()
        
            gridCorpList.DataSource = myDS.Tables("Corp").DefaultView
            gridCorpList.DataBind()
        End Sub
    Stack Overflow
    See the features of Visual Studio 2010 and C# 4.0: The 10-4 show on Channel9

  3. #3

    Thread Starter
    Hyperactive Member kleptos's Avatar
    Join Date
    Aug 2001
    Location
    The Dark Carnival
    Posts
    346
    Thanks!
    ..::[kleptos]::..
    • Database Administrator (MSSQL 2000)
    • Application Developer (C#)
    • Web Developer (ASP.NET)


Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width