实现自定义分页(如:改变传统datagrid的分页显示、通过A-Z的字母来分页等)、选择的check

2016-01-29 12:45 15 1 收藏

实现自定义分页(如:改变传统datagrid的分页显示、通过A-Z的字母来分页等)、选择的check,实现自定义分页(如:改变传统datagrid的分页显示、通过A-Z的字母来分页等)、选择的check

【 tulaoshi.com - ASP.NET 】

代码using System;using System.Collections;using System.ComponentModel;using System.Data;using System.Drawing;using System.Web;using System.Web.SessionState;using System.Web.UI;using System.Web.UI.WebControls;using System.Web.UI.HtmlControls;namespace DataGridDemoCS{ /// /// Demo1 的摘要说明。 /// public class DemoFinal : System.Web.UI.Page { protected System.Data.SqlClient.SqlConnection sqlConnection1; protected System.Data.SqlClient.SqlDataAdapter sqlDataAdapter1; //注意:dataset在编辑状态中将清空,所以可以将dataset申明为static,这样就可以保持dataset状态; //静态成员变量不可以用this来调用 protected DataGridDemoCS.dsCustomers dsCustomers1; protected DataGridDemoCS.dsCustomers.CustomersDataTable dsCustomerTable; protected DataGridDemoCS.dsCustomers.CustomersRow dsCustomerRow; protected System.Data.SqlClient.SqlCommand sqlSelectCommand1; protected System.Data.SqlClient.SqlCommand sqlInsertCommand1; protected System.Data.SqlClient.SqlCommand sqlUpdateCommand1; protected System.Data.SqlClient.SqlCommand sqlDeleteCommand1; protected System.Data.SqlClient.SqlConnection sqlConnection2; protected System.Web.UI.WebControls.Button Button1; protected System.Web.UI.WebControls.Button BtnInsertOneRow; protected System.Web.UI.WebControls.Button BtnDeleteGrouply; protected System.Web.UI.WebControls.Panel PnlPage; protected System.Data.DataView dv; protected System.Data.SqlClient.SqlDataAdapter sqlDataAdapter2; protected System.Data.SqlClient.SqlConnection sqlConnection3; protected System.Web.UI.WebControls.DataGrid DataGrid1; public int ExpandedItem=7; public Unit HostColumnWidth; private DataGrid detailsGrid; const string ExpandText = "+"; protected System.Data.SqlClient.SqlCommand sqlSelectCommand2; protected System.Data.SqlClient.SqlCommand sqlInsertCommand2; protected System.Data.SqlClient.SqlCommand sqlUpdateCommand2; protected System.Data.SqlClient.SqlCommand sqlDeleteCommand2; protected System.Web.UI.WebControls.Button Button2; const string CollapseText = "-"; private void Page_Load(object sender, System.EventArgs e) { // 在此处放置用户代码以初始化页面 if (!Page.IsPostBack) { ExpandedItem = -1; testWorkFlow=""; ViewState["Sort"]="CustomerID"; ViewState["orderby"]="asc"; bindDate(); BtnDeleteGrouply.Attributes.Add("OnClick","javascript:DeleteGrouply();"); HostColumnWidth = Unit.Pixel(150); } } void bindDate() { testWorkFlow=""; sqlDataAdapter1.Fill(dsCustomers1,"Customers"); if ((string)(ViewState["Sort"])!="") dv.Sort=(string)ViewState["Sort"]+" "+ViewState["orderby"]; else dsCustomers1.Customers.DefaultView.Sort="CustomerID"; if ((string)(ViewState["alpha"])!="") { dv.RowFilter="CustomerID LIKE '"+(string)(ViewState["alpha"])+"%'"; } DataGrid1.DataBind(); m_CreatePageTimes=0; } #region Web 窗体设计器生成的代码 override protected void OnInit(EventArgs e) { // // CODEGEN: 该调用是 ASP.NET Web 窗体设计器所必需的。 // InitializeComponent(); base.OnInit(e); } /// /// 设计器支持所需的方法 - 不要使用代码编辑器修改 /// 此方法的内容。 /// private void InitializeComponent() { this.sqlConnection1 = new System.Data.SqlClient.SqlConnection(); this.sqlDataAdapter1 = new System.Data.SqlClient.SqlDataAdapter(); this.sqlDeleteCommand1 = new System.Data.SqlClient.SqlCommand(); this.sqlConnection2 = new System.Data.SqlClient.SqlConnection(); this.sqlInsertCommand1 = new System.Data.SqlClient.SqlCommand(); this.sqlSelectCommand1 = new System.Data.SqlClient.SqlCommand(); this.sqlUpdateCommand1 = new System.Data.SqlClient.SqlCommand(); this.dsCustomers1 = new DataGridDemoCS.dsCustomers(); this.dv = new System.Data.DataView(); this.sqlDataAdapter2 = new System.Data.SqlClient.SqlDataAdapter(); this.sqlDeleteCommand2 = new System.Data.SqlClient.SqlCommand(); this.sqlConnection3 = new System.Data.SqlClient.SqlConnection(); this.sqlInsertCommand2 = new System.Data.SqlClient.SqlCommand(); this.sqlSelectCommand2 = new System.Data.SqlCl

来源:https://www.tulaoshi.com/n/20160129/1487419.html

延伸阅读
标签: SQLServer
  分页存储过程代码如下: ALTER PROCEDURE [dbo].[Task_SelectPagedAndSorted] (     @ProjectID uniqueidentifier,     @ProjectAreaID uniqueidentifier,     @DepartmentID uniqueidentifier,     @ChiefID uniqueidentifier,     @State nvarchar(32), ...
标签: Web开发
代码如下: !-- //ASP分页函数 function ShowListPage(page,Pcount,TopicNum,maxperpage,strLink,ListName){     var alertcolor = '#FF0000';     maxperpage=Math.floor(maxperpage);     TopicNum=Math.floor(TopicNum);     p...
标签: Web开发
今天心情有点激动,想把"关于用DW+ASP实现分页技术的参考"分享给用DW+ASP做网页的朋友们.去掉只有"第一页,前一页,下一页,最后一页"的小痛苦 此效果最后的显示是:第N页[共*页] 1 2 3 4 5 6 7 8 9 10 。 用DW+ASP做网页时,在绑定记录集后,代码页里马上出现以下代码: %  Dim Recordset1  Dim Recordset1_numRows&nb...
标签: Web开发
From: IECN.Net ; Author: 钟钟 /**  * 分页类构造  * 参数 nTotalList: 总条数  * 参数 nPageSize: 每页显示条数  * 参数 nPageNum: 当前页码  * 参数 sPageUrl: 分页链接的URL,页码以[pn]代替,输出时将被替换为实际...

经验教程

875

收藏

9
微博分享 QQ分享 QQ空间 手机页面 收藏网站 回到头部