Click to See Complete Forum and Search --> : Datagrid Paging Question
kleptos
Oct 17th, 2002, 01:26 PM
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#?
Cander
Oct 17th, 2002, 01:59 PM
example..in VB..sorry but ahould be simple to convert to c#
<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>
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
kleptos
Oct 17th, 2002, 02:33 PM
Thanks!
vbforums.com
Copyright Internet.com Inc., All Rights Reserved.