当前位置: 首页 > 图文教程 > 网络编程 > ASP.NET > ASP.NET的Web controls(二)

ASP.NET
FreeTextBox(版本3.1.6)在ASP.Net 2.0中使用方法
.NET 常用功能和代码小结
在 .NET Framework 2.0 中未处理的异常导致基于 ASP.NET 的应用程序意外退出
asp.net IList查询数据后格式化数据再绑定控件
asp.net sql存储过程
asp.net 简单实现禁用或启用页面中的某一类型的控件
asp.net(c#)获取内容第一张图片地址的函数
The remote procedure call failed and did not execute的解决办法
ASP.NET 在线文件管理
asp.net 读取并修改config文件实现代码
ASP.NET Cookie 操作实现
asp.net Silverlight中的模式窗体
Silverlight中动态获取Web Service地址
asp.net Silverlight应用程序中获取载体aspx页面参数
asp.net 水晶报表隔行换色实现方法
asp.net 获取Gridview隐藏列的值
手动把asp.net的类生成dll文件的方法
asp.net 使用ObjectDataSource控件在ASP.NET中实现Ajax真分页
动态指定任意类型的ObjectDataSource对象的查询参数
asp.net Md5的用法小结

ASP.NET的Web controls(二)


出处:互联网   整理: 软晨网(RuanChen.com)   发布: 2009-11-03   浏览: 54 ::
收藏到网摘: n/a

crystal译·yesky

  也许在这个新的 controls中最有趣的莫过于 DataGrid。Datagrid是一个多列的数据绑定网格,通过它你可以轻而易
举的将数据置于其中。它同时提供分页、排序等所有你所期望的功能。我们看一个Datagrid的例子.

  注:我们将在另外的文章里介绍Datagrid的属性和方法。

<%@ Page language="C#" src="DataGrid.cs" inherits="Samples.DataGridPage"%>
...

<asp:DataGrid runat=server id="titlesGrid">
</asp:DataGrid>

  上面的 .aspx 文件显示在不设置 DataGrid 控件任何属性的情况下对其进行声明。

DataGrid.cs:

namespace Samples {
...

public class DataGridPage : Page {
protected DataGrid titlesGrid;

public ICollection GetTitlesList() {

// 从在应用程序状态中高速缓存的 DataSet 中检索标题列表。
DataSet titlesDataSet = (DataSet)Application["TitlesDataSet"];

if (titlesDataSet != null) {
return titlesDataSet.Tables["Title"].DefaultView;
}
else {
return null;
}
}

private void LoadTitlesGrid() {

// 从数据库中检索数据
ICollection titlesList = GetTitlesList();

// 设置控件的数据源
titlesGrid.DataSource = titlesList;

// 并使它用此数据源构建其项目
titlesGrid.DataBind();
}

protected override void OnLoad(EventArgs e) {
base.OnLoad(e);

if (!IsPostBack) {

// 首次请求此页
LoadTitlesGrid();
}
}
}
}

  记录丢失,对于程序员来说是一个非常严重的事情。在新的系统中, 中心对象是Dataset。它与recordset相类似,是
数据内在存储记忆的副本。Dataset对于您的开发来说是中心所在,但是现在,我只能说它只是相近与XML,使程式在简单
化和统一化的过程中,相对简单。你还是可以用你过去用过的来处理一切…(除了服务器端游标)…