选择显示字体大小

使用 asp.net atlas pagenavigator控件实现客户端分页导航


  english version: http://dflying.dflying.net/1/archive/127_paging_your_list_using_as.net_atlas_pagenavigator_control.html

在这个系列中,我将介绍一些atlas sys.ui.data中较高级的控件,包括:

sys.ui.data.listview:使用asp.net atlas listview控件显示列表数据
sys.ui.data.itemview:使用asp.net atlas itemview控件显示集合中的单个数据
sys.ui.data.datanavigator:使用 asp.net atlas pagenavigator控件实现客户端分页导航
sys.ui.data.sortbehavior:待续

sys.ui.data.xsltview:待续
这篇是其中的第三篇:使用 asp.net atlas pagenavigator控件实现客户端分页导航
把所有的记录统统放在一个页面上绝对不是一个好主意,特别是当您有成百上千条记录时。您的用户需要不停的拖动滚动条,甚至使用control+f来找到所期待的内容,这将带来相当差的用户体验。这时,将数据以分页的方式显示给用户将友好的多。一些asp.net服务器端控件拥有内建的分页及页面导航功能,例如datagrid和gridview。同样的,atlas客户端控件sys.ui.data.datanavigator也提供了类似的功能,这将大大提高我们的开发效率。

datanavigator控件将与dataview(请参考:atlas命名空间sys.data下控件介绍——dataview和datafilter )控件一起工作。我们知道dataview控件没有提供页面导航相关方法,所以我们只能直接设置它的pageindex属性来实现导航。虽然没有什么难度,但很多情况下这并不是一个好办法,因为像我这样好多粗心的开发者往往会忘记检查pageindex的边界值,造成不必要的麻烦。这也是atlas要提供datanavigator控件的原因之一,datanavigator控件将作为一个dataview控件的代理(proxy),提供易用的页面导航接口。

datanavigator对象只有一个属性:

dataview:对某个dataview对象的引用,这个datanavigator将把页面导航的操作应用到其上。您应该总是指定这个属性。
另外,要使用datanavigator控件,您还需要提供一些拥有一些指定commandname属性的atlas button,以触发相应的页面导航操作。这些button的parent属性应该设定为此datanavigator控件,以保证datanavigator能够捕获到这些button发出的命令。

您可以指定您的button的commandname属性为如下五个string,每个都有不同的含义:

page:将当前页面索引转为命令参数(command argument)中指定的值。通过这个命令我们可以快速的改变页面的索引
nextpage:切换到下一页(如果存在下一页)。
previouspage:切换到上一页(如果存在上一页)。
firstpage:切换到第一页。
lastpage:切换到最后一页。
ok,msdn般枯燥的介绍到此为止吧,让我们通过一个实例来熟悉datanavigator的使用方法。

首先我们需要暴露一个web service,以便atlas页面使用。该web service将返回100条记录。下面就是这个web service的代码,非常易于理解,这里不赘。

web service
using system;
using system.collections;
using system.collections.generic;
using system.componentmodel;
using system.io;
using system.web;
using system.web.caching;
using system.web.services;
using system.web.services.protocols;
using microsoft.web.services;

//
// for simplicity this example demonstraes storing and manipulating
// the data objects in memory. a database can also be used.
//

[webservice(namespace = "http://tempuri.org/")]
[webservicebinding(conformsto = wsiprofiles.basicprofile1_1)]
public class mydataservice : dataservice
{
static list<entry> _data;
static object _datalock = new object();

private static list<entry> data
{
get
{
if (_data == null)
{
lock (_datalock)
{
if (_data == null)
{
_data = new list<entry>();
for (int i = 0; i < 100; i++)
{
_data.add(new entry(i, "dflying " + i.tostring(), string.format("dflying{0}@dflying.net", i.tostring())));
}
}
}
}
return _data;
}
}
[dataobjectmethod(dataobjectmethodtype.select)]
public entry[] selectrows()
{
return mydataservice.data.toarray();
}
}

public class entry
{
private string _name;
private string _email;
private int _id;

[dataobjectfield(true, true)]
public int id
{
get { return _id; }
set { _id = value; }
}

[dataobjectfield(false)]
[defaultvalue("new row")]
public string name
{
get { return _name; }
set { _name = value; }
}

[dataobjectfield(false)]
[defaultvalue("")]
public string email
{
get { return _email; }
set { _email = value; }
}

public entry()
{
_id = -1;
}

public entry(int id, string name, string description)
{
_id = id;
_name = name;
_email = description;
}
}
然后,在aspx页面中我们需要考虑并定义如下四部分的内容:


 


关键字 本文所属关键字

相关 与本文相关文章

分类 所有文章关键字导航

源码编程相关

Java   Asp   PHP   .Net   XML   C/C++   CGI   VB   Jsp   J2ee   J2se   J2me   EJB   Servlet   Tomcat   Resin   Struts   Weblogic   Eclipse   ANT   GUI   JMS   Web servise   IDEA   Webphere   Hibernate   Spring   Jboss   Applet   Swing   Socket   Javamail   Perl   Ajax   P2P   安全   模式   框架   测试   开源   游戏

SQL数据库相关

My-SQL   Ms-SQL   Access   DB2   Oracle   Sybase   SQLserver   索引   存储过程   加密   数据库   分页   视图  

手机无线相关

3G   Wap   CDMA   GRPS   GSM   IVR   彩信   短信   无线   增值业务

网页设计制作相关

HTML   CSS   网页配色   网页特效   Javascript   VBscript   Dreamweaver   Frontpage   JS   Web   网站设计

网站建设推广相关

建站经验   网站优化   网站排名   推广   Alexa

操作系统/服务器相关

Windows XP   Windows 2000   Windows 2003   Windows Me   Windows 9.x   Linux   UNIX   注册表   操作系统   服务器   应用服务器

图形图像多媒体相关

Photoshop   Fireworks   Flash   Coreldraw   Illustrator   Freehand   Photoimpact   多媒体   图形图像

标准 网站致力的规范

Valid CSS!

无不良内容,无不良广告,无恶意代码

Valid XHTML 1.0 Transitional

creativecommons