|
马上注册,结交更多好友,享用更多功能,让你轻松玩转社区。
您需要 登录 才可以下载或查看,没有帐号?立即注册
x
使用filesystemobject,可以对服务器上的文件进行操作,浏览、复制、移动、删除等。有ado的支持,asp对数据库的操作非常得心应手。你甚至可以像使用本地数据库那样,管理远程主机上的数据库,对表格、记录进行各种操作。datagrid|分页|排序<%@Pagelanguage="c#"Codebehind="default.aspx.cs"AutoEventWireup="false"Inherits="datagrid.WebForm1"%>
<!DOCTYPEHTMLPUBLIC"-//W3C//DTDHTML4.0Transitional//EN">
<HTML>
<HEAD>
<title>WebForm1</title>
<metacontent="MicrosoftVisualStudio.NET7.1"name="GENERATOR">
<metacontent="C#"name="CODE_LANGUAGE">
<metacontent="JavaScript"name="vs_defaultClientScript">
<metacontent="http://schemas.microsoft.com/intellisense/ie5"name="vs_targetSchema">
</HEAD>
<bodyMS_POSITIONING="GridLayout">
<formid="Form1"method="post"runat="server">
<script>
window.resizeTo(screen.width,screen.height-30);
</script>
<asp:datagridid="DataGrid1"style="Z-INDEX:101;LEFT:48px;POSITION:absolute;TOP:56px"runat="server"
HorizontalAlign="Center"DataKeyField="au_id"PageSize="3"AllowPaging="True"Width="408px"
AutoGenerateColumns="False"AllowSorting="True">
<Columns>
<asp:BoundColumnDataField="au_id"SortExpression="au_id"ReadOnly="True"HeaderText="ID"></asp:BoundColumn>
<asp:BoundColumnDataField="city"SortExpression="city"ReadOnly="True"HeaderText="乡村"></asp:BoundColumn>
<asp:TemplateColumnSortExpression="au_id"HeaderText="操纵">
<ItemTemplate>
<asp:LinkButtonrunat="server"ID="delbutton"Text="删除"CommandName="Delete"CausesValidation="false"></asp:LinkButton>
</ItemTemplate>
</asp:TemplateColumn>
</Columns>
<PagerStyleVisible="False"PageButtonCount="6"></PagerStyle>
</asp:datagrid><asp:labelid="Label1"style="Z-INDEX:106;LEFT:312px;POSITION:absolute;TOP:24px"runat="server"></asp:label><asp:linkbuttonid="LBtfir"style="Z-INDEX:105;LEFT:72px;POSITION:absolute;TOP:24px"runat="server">首页</asp:linkbutton><asp:linkbuttonid="LBtlast"style="Z-INDEX:104;LEFT:256px;POSITION:absolute;TOP:24px"runat="server">尾页</asp:linkbutton><asp:linkbuttonid="LBtpre"style="Z-INDEX:103;LEFT:192px;POSITION:absolute;TOP:24px"runat="server">上一页</asp:linkbutton><asp:linkbuttonid="LBtnex"style="Z-INDEX:102;LEFT:120px;POSITION:absolute;TOP:24px"runat="server">下一页</asp:linkbutton></form>
</body>
</HTML>
代码
default.aspx.cs
usingSystem;
usingSystem.Collections;
usingSystem.ComponentModel;
usingSystem.Data;
usingSystem.Data.SqlClient;
usingSystem.Drawing;
usingSystem.Web;
usingSystem.Web.SessionState;
usingSystem.Web.UI;
usingSystem.Web.UI.WebControls;
usingSystem.Web.UI.HtmlControls;
namespacedatagrid
{
///<summary>
///WebForm1的择要申明。
///</summary>
publicclassWebForm1:System.Web.UI.Page
{
protectedSystem.Web.UI.WebControls.LinkButtonLBtnex;
protectedSystem.Web.UI.WebControls.LinkButtonLBtpre;
protectedSystem.Web.UI.WebControls.LinkButtonLBtlast;
protectedSystem.Web.UI.WebControls.LinkButtonLBtfir;
protectedSystem.Web.UI.WebControls.LabelLabel1;
protectedSystem.Web.UI.WebControls.DataGridDataGrid1;
publicstringSortField;
privatevoidPage_Load(objectsender,System.EventArgse)
{
//在此处安排用户代码以初始化页面
if(!Page.IsPostBack)
{
databind();
}
}
publicvoiddatabind()
{
SqlConnectioncon=newSqlConnection("server=it003;database=pubs;uid=sa;pwd=");
con.Open();
stringsql="select*fromauthors";
SqlDataAdapterada=newSqlDataAdapter(sql,con);
DataSetds=newDataSet();
ada.Fill(ds,"temp");
ds.Tables["temp"].DefaultView.Sort=SortField;
DataGrid1.DataSource=ds.Tables["temp"].DefaultView;
DataGrid1.DataBind();
ada.Di</p>问题是他们究竟是喜欢他们是使用软件时,速度快还是速度慢好.(当然在3秒以内).无论是他们输入资料时,查找资料时,分析资料时. |
|