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

2016-01-29 12:45 17 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

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

延伸阅读
标签: PHP
  <html<body<table border=1 <? $id=@mssql_connect("ddy","sa"," ") or die("连接不上"); $db=mssql_select_db("ddy",$id); $query="select * from lr00 order by lr0012 desc"; $result=mssql_query($query); if($result): if($tt==""){ $...
标签: Web开发
DataGrid是一个功能非常强大的ASP.NET Web服务器端控件,它除了能够方便地按各种方式格式化显示表格中的数据,还可以对表格中的数据进行动态的排序、编辑和分页。使Web开发人员从繁琐的代码中解放。实现DataGrid的分页功能一直是很多初学ASP.NET的人感到棘手的问题,特别是自定义分页功能,实现方法多种多样,非常灵活。本文将向大家介绍一...
标签: Web开发
From: IECN.Net ; Author: 钟钟 /**  * 分页类构造  * 参数 nTotalList: 总条数  * 参数 nPageSize: 每页显示条数  * 参数 nPageNum: 当前页码  * 参数 sPageUrl: 分页链接的URL,页码以[pn]代替,输出时将被替换为实际...
标签: PHP
  <?php $pagesize = 3;//设置每页显示数目 //计算总记录数 $rs_num = "select count(*) as id from table"; $rs_num = odbc_exec($conn_id,$rs_num); $rs_num = odbc_result($rs_num,"id"); //计算总页数 $pagecount = $rs_num / $pagesize; $pagecount1 = intval($pagecount);//将总页数取整 $comp...
标签: Web开发
代码如下: !-- //ASP分页函数 function ShowListPage(page,Pcount,TopicNum,maxperpage,strLink,ListName){     var alertcolor = '#FF0000';     maxperpage=Math.floor(maxperpage);     TopicNum=Math.floor(TopicNum);     p...

经验教程

307

收藏

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