首先创建数据库导入测试数据数据库很简单结构如下
使用如下sql语句导入条记录
declare @i int
set @i=
while(@i<)
Begin
set @i=@i+
insert into LargeData(colcolcol) values(第一列数据第二列数据第三列数据 );
End
go
好了测试数据准备完毕现在我们用GridView来显示这条数据
Defaultaspx的代码如下
代码
<%@ Page Language=C# AutoEventWireup=true CodeFile=Defaultaspxcs Inherits=_Default %>
<!DOCTYPE html PUBLIC //WC//DTD XHTML Transitional//EN transitionaldtd>
<html xmlns= >
<head runat=server>
<meta httpequiv=contenttype content=text/html;charset=utf />
<title>Loading</title>
<script type=text/javascript src=></script>
</head>
<body >
<div id=progressBar >加载中请稍候<img alt=加载中 src=gif/></div>
<form id=form runat=server>
<div id=content >
<asp:GridView ID=GridView runat=server AutoGenerateColumns=False EnableViewState=False>
<Columns>
<asp:BoundField DataField=col HeaderText=COL />
<asp:BoundField DataField=col HeaderText=COL />
<asp:BoundField DataField=col HeaderText=COL />
</Columns>
</asp:GridView>
</div>
</form>
<script type=text/javascript>
$(#content)show();
$(#progressBar)fadeOut();
</script>
</body>
</html>
后台Defaultaspxcs很简单代码如下
代码
using System;
using SystemData;
using SystemConfiguration;
using SystemWeb;
using SystemWebSecurity;
using SystemWebUI;
using SystemWebUIWebControls;
using SystemWebUIWebControlsWebParts;
using SystemWebUIHtmlControls;
using SystemDataSqlClient;
public partial class _Default : SystemWebUIPage
{
private const string SQL_GET_NUM = SELECT * FROM [Demo][dbo][LargeData];
protected void Page_Load(object sender EventArgs e)
{
ResponseFlush();
Bind();
}
private void Bind()
{
using (SqlConnection con = new SqlConnection(ConfigurationManagerConnectionStrings[SqlConStr]ConnectionString))
{
SqlCommand cmd = new SqlCommand(SQL_GET_NUM con);
cmdConnectionOpen();
ResponseFlush();
GridViewDataSource = cmdExecuteReader(CommandBehaviorCloseConnection);
GridViewDataBind();
}
}
}