All articles| All Pictures| All Softwares| All Video| Go home page| Write articles| Upload pictures

Reading number is top 10 articles
C#中的多媒体技术:文字处理
实例详细讲解PHP连接调用数据库的方法_php资料_编程技术
LINQ体验(1)——Visual,Studio,2008新特性_[Asp.Net教程]
Sql,Server2005实现远程备份数据库_mssql学习_编程技术
调用存储过程并且使用返回值的基本方法_[SQL,Server教程]
当ASP.NET撞上JSF之应用程序的国际化_[Asp.Net教程]
教你简单方便获取Web设计的免费资源_.net资料_编程技术
获得汉字字符串的首个拼音字母的缩写_.net资料_编程技术
在C#中调用视图
ASP.NET中的STREAMREADER对象总结_[Asp.Net教程]
Reading number is top 10 pictures
看如何给单纯的少女洗脑
Wear bikinis cock
西游日记1
传几朵花
Wild animals melee moment of life and death2
Summer is most suitable for young people to travel in China2
Plump, too plump!2
The money of more than 100 countries and regions14
9.3阅兵全景图5-地空反舰导弹梯队
The little woman's bright wire2
Download software ranking
WebService在.NET中的实战应用教学视频 → 第2集
Unix video tutorial5
Tram sex maniac 2 (H) rar bag14
Boxer vs Yellow4
功夫熊猫2(上集)
美女写真3
Such love down(擒爱记)
DreamWeaver8
Tram sex maniac 2 (H) rar bag4
Unix video tutorial15
aaa published in(发表于) 2013/12/13 9:38:58 Edit(编辑)
ASP.NET,2.0数据处理之高级分页

ASP.NET,2.0数据处理之高级分页

ASP.NET 2.0数据处理之高级分页/排序_.net资料_编程技术-你的首页-uuhomepage.com
  GridView控件中的"选择"操作纯粹是一个UI概念,它的SelectedIndex属性与表格的可视数据行中的当前被选中的行的索引相对应。如果你启用了表格的分页和排序功能,在执行分页或排序操作之后,SelectedIndex的值仍然不会变化,因此在执行这些操作之后,一个新数据行被选中了。在某些环境下,保留对指定数据行的选中更好,即使该行在表格的当前页面中并不可视。下面的例子演示了如何在排序和分页操作之后仍然保留当前选中的数据行。


Sub GridView1_DataBound(ByVal sender As Object, ByVal e As System.EventArgs)
 Dim Row As GridViewRow
 Dim SelectedValue As String = ViewState("SelectedValue")
 If SelectedValue Is Nothing Then
  Return
 End If
 ' 检测选择的行是哪个并重新选中它
 For Each Row In GridView1.Rows
  Dim KeyValue As String = GridView1.DataKeys(Row.RowIndex).Value
  If (KeyValue = SelectedValue) Then
   GridView1.SelectedIndex = Row.RowIndex
  End If
 Next
End Sub

Protected Sub GridView1_SelectedIndexChanged(ByVal sender As Object, ByVal e As System.EventArgs)
 ' 保存选中行的索引
 If (Not GridView1.SelectedIndex = -1) Then
  ViewState("SelectedValue") = GridView1.SelectedValue
 End If
End Sub

Protected Sub GridView1_PageIndexChanging(ByVal sender As Object, ByVal e As System.Web.UI.WebControls.GridViewPageEventArgs)
 ' 重置选中索引
 GridView1.SelectedIndex = -1
End Sub

Sub GridView1_Sorting(ByVal sender As Object, ByVal e As System.Web.UI.WebControls.GridViewSortEventArgs)
 ' 重置选择索引
 GridView1.SelectedIndex = -1
End Sub

  GridView和DetailsView还支持一种用于分页和排序的特殊模式,它利用客户端向服务器的回调(callback)操作来获取新页面的数据或最近排序过的数据。要激活这个特性,必须把EnableSortingAndPagingCallbacks属性设置为真。请注意,当我们执行分页或排序操作的时候,页面不需要发回(postback)以检索新值(尽管执行了客户端脚本向服务器的回调操作)。当GridView或DetailsView包含模板字段的时候是不支持这个特性的。当这个特性被激活的时候,不支持在CommandField(命令字段)中显示"选择"按钮。


<asp:GridView AllowPaging="True" AllowSorting="True" AutoGenerateColumns="False" DataKeyNames="au_id" DataSourceID="SqlDataSource1" EnableSortingAndPagingCallbacks="True" ID="GridView1" runat="server">
……
</asp:GridView>

  尽管GridView、DetailsView和FormView为分页器(pager)UI提供了默认的显示方式,你仍然可以通过设置PagerTemplate属性来自定义分页器的显示。在这个模板中,你可以放置按钮控件,并把它的CommandName属性设置为Page,把它的属性设置为First、Prev、Next、Last或<number>,其中<number>是特定页面的索引值。下面的例子演示了GridView和DetailsView控件定义的PagerTemplate。


<PagerTemplate>
<asp:LinkButton CommandName="Page" CommandArgument="First" ID="LinkButton1" runat="server" Style="color: white"><< First</asp:LinkButton>
<asp:LinkButton CommandName="Page" CommandArgument="Prev" ID="LinkButton2" runat="server" Style="color: white">< Prev</asp:LinkButton>
[Records <%= GridView1.PageIndex * GridView1.PageSize %> - <%= GridView1.PageIndex * GridView1.PageSize + GridView1.PageSize - 1 %>]
<asp:LinkButton CommandName="Page" CommandArgument="Next" ID="LinkButton3" runat="server" Style="color: white">Next ></asp:LinkButton>
<asp:LinkButton CommandName="Page" CommandArgument="Last" ID="LinkButton4" runat="server" Style="color: white">Last >></asp:LinkButton>
</PagerTemplate>




添加到del.icio.us 添加到新浪ViVi 添加到百度搜藏 添加到POCO网摘 添加到天天网摘365Key 添加到和讯网摘 添加到天极网摘 添加到黑米书签 添加到QQ书签 添加到雅虎收藏 添加到奇客发现 diigo it 添加到饭否 添加到飞豆订阅 添加到抓虾收藏 添加到鲜果订阅 digg it 貼到funP 添加到有道阅读 Live Favorites 添加到Newsvine 打印本页 用Email发送本页 在Facebook上分享


Disclaimer Privacy Policy About us Site Map

If you have any requirements, please contact webmaster。(如果有什么要求,请联系站长)
Copyright ©2011-
uuhomepage.com, Inc. All rights reserved.