求助关于DELPHI8的DATAGRID分页的编程实现方法?(50分)

  • 主题发起人 主题发起人 redhawk
  • 开始时间 开始时间
R

redhawk

Unregistered / Unconfirmed
GUEST, unregistred user!
我在delphi8中创建了DataGrid,并连接了ORACLE数据库,DataGrid取得了数据,设置了分页功能,但是点击下一页和上一页,不能变换DataGrid内容,还是第一页的内容,写了DataGrid1_PageIndexChanged事件,给如何实现分页?能提供一个源程序吗?谢谢!
我的代码如下,DataGrid的数据我要动态的更新。
procedure TWebForm1.Button6_Click(sender: System.Object;
e: System.EventArgs);
begin
OracleDataAdapter1.SelectCommand.CommandText:='select ch,sj,thl,ghl,fxy from D14_HYS_YLYFXBB_1_1 order by ch';
OracleDataAdapter1.Fill(Dataset1);
DataView1:=DataSet1.Tables[0].DefaultView;
DataGrid2.VirtualItemCount:=DataView1.Count;
DataGrid2.CurrentPageIndex:=0;
DataGrid2.DataSource:=DataView1;
DataGrid2.DataBind();
end;

procedure TWebForm1.DataGrid2_PageIndexChanged(source: System.Object;
e: System.Web.UI.WebControls.DataGridPageChangedEventArgs);
begin

DataGrid2.CurrentPageIndex:=e.NewPageIndex;
OracleDataAdapter1.SelectCommand.CommandText:='select ch,sj,thl,ghl,fxy from D14_HYS_YLYFXBB_1_1 order by ch';
OracleDataAdapter1.Fill(Dataset1);
DataView1:=DataSet1.Tables[0].DefaultView;
DataGrid2.VirtualItemCount:=DataView1.Count;
//DataGrid2.CurrentPageIndex:=0;
DataGrid2.DataSource:=DataView1;
DataGrid2.DataBind();
end;
 
急需解决,顶。
谢谢!
 
<html>
<HEAD>
<TITLE>ASP.NET的数据排序、分页功能</TITLE>
</HEAD>
<%@Import NameSpace="System.Data" %>
<%@Import Namespace="System.Data.OleDb"%>
<script language="VB" runat="server">
Dim MyCommand As OleDbDataAdapter
Dim String1 As String
Dim MyDataSet As DataSet
Sub Page_Load(Sender As Object,e As EventArgs)
String1="Provider=Microsoft.Jet.OLEDB.4.0;Data Source = "&amp;Server.MapPath(" MyDataBase.MDB")
MyCommand = New OleDbDataAdapter("Select * from 学生和课程",String1)
MyDataSet=New DataSet()
MyCommand.Fill(MyDataSet,"学生和课程")
MyDataGrid.DataSource = MyDataSet
MyDataGrid.DataMember = "学生和课程"
MyDataGrid.DataBind()
End Sub
Sub PageIndexChanged(sender As Object, e As DataGridPageChangedEventArgs)
String1="Provider=Microsoft.Jet.OLEDB.4.0;Data Source = "&amp;Server.MapPath(" MyDataBase.MDB")
MyCommand = New OleDbDataAdapter("Select * from 学生和课程",String1)
MyDataSet=New DataSet()
MyCommand.Fill(MyDataSet,"学生和课程")
MyDataGrid.DataSource = MyDataSet
MyDataGrid.CurrentPageIndex = e.NewPageIndex
MyDataGrid.DataBind()
End Sub
</script>
<body>
<form runat="server">
<asp:DataGrid AllowPaging="True" PagerStyle-Mode="NumericPages"
PageStyle-PrevPageText="Prev" PageStyle-NextPageText="Next"
BorderColor="blue" HorizontalAlign="Center" GridLines="Both"
PageSize="5" CellPadding="10" CellSpacing="2"
HeaderStyle-BackColor="#CCFF33"
OnPageIndexChanged="PageIndexChanged"
id="MyDataGrid" runat="server">
</asp:DataGrid>
</form>
</body>
</html>
 
我试了不行
 
后退
顶部