自定义DataGrid分页设置

FPGA实战:手把手教你实现VESA DSC编码(附Verilog代码解析) 本文详细介绍了如何使用FPGA实现VESA DSC编码器,包括核心架构设计、Verilog代码实现与优化技巧。通过流水线设计、色彩空间转换和预测编码等关键技术,帮助开发者掌握工业级DSC编码器的开发流程,并提供实用的调试与性能优化方法。 阅读详情
自定义DataGrid分页设置

源作者:追风                   人气:13974

  这里我实现了DataGrid的个性化分页,现在把代码贴出来朋友们参考,同时在这个功能的实现过程,参考了“飞刀”从国外翻译的一篇文章。


  先定义ASPX页面,注意AllowCustomPaging要设为"False":
<body>
  <form id="DictList" method="post" runat="server">
      <TABLE style="BORDER-COLLAPSE: collapse" cellSpacing="0" width="100%" border="1">
    <TR>
     <td bgColor="#c0c000">信息:<FONT face="Arial" color="#ffffff">数据维护</FONT>
     </td>
    </TR>
    <tr>
     <td><FONT face="宋体"></FONT></td>
    </tr>
    <tr>
     <td><asp:datagrid id="MyDataGrid" runat="server" Width="100%" PageSize="20" AllowPaging="True" AutoGenerateColumns="False" DataKeyField="FDictid">
       <SelectedItemStyle BackColor="#FFC080"></SelectedItemStyle>
       <HeaderStyle BackColor="#C0C000"></HeaderStyle>
       <Columns>
        <asp:ButtonColumn Text="选择" HeaderText="选择" CommandName="Select">
         <HeaderStyle Font-Bold="True" HorizontalAlign="Center" Width="8%"></HeaderStyle>
         <ItemStyle Font-Bold="True" HorizontalAlign="Center"></ItemStyle>
        </asp:ButtonColumn>
        <asp:BoundColumn DataField="FDictID" SortExpression="FDictID asc" HeaderText="标识号">
         <HeaderStyle Width="15%"></HeaderStyle>
        </asp:BoundColumn>
        <asp:BoundColumn DataField="FNameCn" SortExpression="FNameCn asc" HeaderText="名称">
         <HeaderStyle Width="15%"></HeaderStyle>
        </asp:BoundColumn>
        <asp:BoundColumn DataField="FNameEn" SortExpression="FNameEn asc" HeaderText="英文名称">
         <HeaderStyle Width="15%"></HeaderStyle>
        </asp:BoundColumn>
        <asp:BoundColumn DataField="FNote" SortExpression="FNote asc" HeaderText="描叙">
         <HeaderStyle Width="47%"></HeaderStyle>
        </asp:BoundColumn>
       </Columns>
       <PagerStyle Visible="False"></PagerStyle>
      </asp:datagrid></td>
    </tr>
   </TABLE>
   <TABLE style="BORDER-COLLAPSE: collapse" cellSpacing="0" width="100%" bgColor="#ff9966" border="1">
    <TR>
     <td align="right"><asp:linkbutton id="btnFirst" runat="server" CommandArgument="fist">首页</asp:linkbutton>&nbsp;&nbsp;
      <asp:linkbutton id="btnPrev" runat="server" Width="36px" CommandArgument="prev">上一页</asp:linkbutton>&nbsp;&nbsp;
      <asp:linkbutton id="btnNext" runat="server" CommandArgument="next">下一页</asp:linkbutton>&nbsp;&nbsp;
      <asp:linkbutton id="btnLast" runat="server" CommandArgument="last">末页</asp:linkbutton>&nbsp;&nbsp;
      <asp:label id="lblCurrentIndex" runat="server"></asp:label>/<asp:label id="lblPageCount" runat="server"></asp:label>&nbsp;&nbsp;
      跳转到<asp:TextBox id="txtGoPage" runat="server" Width="30px" CssClass="textbox"></asp:TextBox>
      <asp:Button id="btnGo" runat="server" Text="GO" CssClass="button" Width="29px"></asp:Button></td>
    </TR>
   </TABLE>
  </form>


 


codebehind主要功能部分代码:


  private void Page_Load(object sender, System.EventArgs e)
  {
   // 在此处放置用户代码以初始化页面
   myConnection = new SqlConnection(System.Configuration.ConfigurationSettings.AppSettings["ConnString"]);
 
   if (!IsPostBack)
    BindGrid();
  }


  public void BindGrid()
  {
   string strSql ="SELECT * FROM t_dict ";
   SqlDataAdapter myCommand = new SqlDataAdapter(strSql, myConnection);
   DataSet ds = new DataSet();
   myCommand.Fill(ds, "t_dict");
   MyDataGrid.DataSource=ds.Tables["t_dict"].DefaultView;
   MyDataGrid.DataBind(); 
   ShowStatsPage();
  }
 
  private void PagerButtonClick(object sender, System.EventArgs e)
  {
   //获得LinkButton的参数值
   String arg = ((LinkButton)sender).CommandArgument;
         
   switch(arg)
   {
    case ("next"):
     if (MyDataGrid.CurrentPageIndex < (MyDataGrid.PageCount - 1))
      MyDataGrid.CurrentPageIndex ++;
     break;
    case ("prev"):
     if (MyDataGrid.CurrentPageIndex > 0)
      MyDataGrid.CurrentPageIndex --;
     break;
    case ("fist"):
     MyDataGrid.CurrentPageIndex=0;
     break;
    case ("last"):
     MyDataGrid.CurrentPageIndex = (MyDataGrid.PageCount - 1);
     break;
    default:
     //本页值
     MyDataGrid.CurrentPageIndex = Convert.ToInt32(arg);
     break;
   }
   BindGrid();
  }           
         
  void ShowStatsPage()
  {
   //显示页面信息
   lblCurrentIndex.Text = "[<font color="blue">当前为第:" + ((int)MyDataGrid.CurrentPageIndex+1) + "页</font>]";
   lblPageCount.Text = "[<font color="blue">共:" + MyDataGrid.PageCount + "页</font>]";
  }


  private void MyDataGrid_PageIndexChanged(object source, System.Web.UI.WebControls.DataGridPageChangedEventArgs e)
  {
   //处理按下数字的方法
   MyDataGrid.CurrentPageIndex = e.NewPageIndex;
   BindGrid();
  }


  private void btnGo_Click(object sender, System.EventArgs e)
  {
   //页面直接跳转的代码
   if(txtGoPage.Text.Trim()!="")
   {
    int PageI=Int32.Parse(txtGoPage.Text.Trim())-1;
    if (PageI >=0 && PageI < (MyDataGrid.PageCount))
     MyDataGrid.CurrentPageIndex = PageI ;
   }
   BindGrid();
  }
  //----------------------翻页代码结束

ArcGIS基础:点要素分割线要素和提取线要素的交点 第一个实验:【点要素分割线要素】看下原始数据:下图所示,2个红点和一条绿线,用2个点去分割这条线。 找到【数据管理工具】,在找到【要素】,再找到【在点处分割线】,如下图所示。 输入线、点要素,然后在【搜索半径】里输入5米,查看一下结果。 查看结果发现,线段被分割了2段,我们查看一下原因。 发现第2个点与线有一段距离,肯定是大于5米的,所以分割没有成功。可以量测一下距离,重新输入搜索半径。 我们把搜索半径改为200米,勘察结果,被点分割了3段。 接下来使用另外一个工具【在折点处分割线】,如下所示。 阅读详情

相关推荐

DataGrid分页功能

--WPF的DataGrid分页功能,做了许久最后整理出了一个公共的用户控件, --让大家调用,分享一下。 供参考,希望有问题可以评论一下,告诉我互相学习

利用Datagrid做数据分页

作者:二枚目博客:https://www.jianshu.com/p/20462f1f278e引言EasyUI最常用的的数据网格 datagrid 控件 pagination 属性设置...

陈宇明 658

easyui分页设置

datagrid分页设置 在触发onChangePageSize事件时,会同时触发onSelectPage事件。 onSelectPage事件会传递2个参数pageNumber、pageSize. pageSize是页大小,pageNumber为下一次显示的页号,默认从第一页开始。

jquery easy ui datagrid 纯后台分页实现

jquery easyui的datagrid可以容易实现分页,但大多数是实现前台javascirpt分页,如果数据库数据特别大,一次查询的数据交给前台分页,浏览器多半死机。所以需要在后台查询指定的页的数据,送到前台datagrid中,性能才好。 查询指定页的SQL语句并不难,关键问题是:    (1)在SQL中查询了一页的数据,比如10条,在datagrid中只会显示总记录数10条,共

金石软件 1万+

DataGrid控件(二)--分页

数据绑定之后,如果要在DataGrid控件中实现分页功能,那么就要用到DataGrid的Allowpaging属性了,设置AllowPaging属性为True,然后设置每一页的大小,比如说设为2:PageSize=2。这个时候,再运行程序,就会看到DataGrid以每页两条记录的方式来显示了,并且有""来连接到上一页或者下一页,如果你不想用这个"",而想用汉字“上一页”和“下一页”,那么只要在属性

itzhiren的专栏 1763

利用Grid组件进行分页的基础

 概述: 本例将会带你进入Grid分页的世界案例下载:http://www.vinylfox.com/extjs/examples/grid-paging.zip案例演示:http://www.vinylfox.com/extjs/examples/grid-paging/grid-paging-working.php英文原文:http://www.extjs.com/tutorial/basic

mcjentor的专栏 1008

ASP.NET中自定义DataGrid分页设置的实现

<br />先定义ASPX页面,注意AllowCustomPaging要设为"False":<br /><asp:datagrid id="MyDataGrid" runat="server" Width="100%" PageSize="20" AllowPaging="True" AutoGenerateColumns="False" DataKeyField="FDictid"> <br /><Columns> <br /><br /></Columns> <br />  <PagerStyle Vi

Warren专栏 611

自定义DataGrid分页设置C#

 Default.aspx http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> http://www.w3.org/1999/xhtml">     Untitled Page                  信息:数据维护                                              

程序的世界没有顶峰 482

easyUI自定义DataGrid分页

@author YHC datagrid内置一个很好特性的分页功能,自定义也相当简单,在这个教程中,我们将创建一个datagrid 和添加一些自定义按钮在分页工具栏. 查看 Demo 创建 DataGrid <table id="tt" title="Load Data" class="easyui-datagrid" style="width:550px...

weixin_30657541的博客 81

java datagrid控件_Asp.net中DataGrid控件的自定义分页

使用实现起来虽然比较方便,但是效率不高,每次都需要读取所有页(整个记录集),而加载使用实现起来虽然比较方便,但是效率不高,每次都需要读取所有页(整个记录集),而加载的只是其中一页,造成了资源的浪费,记录多又会使效率变得很低。下面通过DataGrid自定义分页功能来减少资源使用和提高效率。实现的关键是设置AllowCustomPaging属性位True,并把VirtualItemCount属性设置...

weixin_39779928的博客 119

使用EasyUI完成datagrid数据分页

      当数据库中的数据量过多时一般都会进行分页操作,下面为大家提供一种EasyUI自带分页的操作,非常简便实用,喜欢EasyUI可以参考一下,希望可以给你带来帮助!    实用EasyUI首先要引用文件,这里不再进行叙述,为了让大家能够明白,现在从数据库一步步讲起。   数据库中的表为Goods表 go create table Goods ( Id int  primary key ...

gods_boy的博客 2万+

Henry手记—Web Form中的Datagrid自定义分页

         Henry手记—Web Form中的Datagrid自定义分页                                  韩睿  ( 05/31/2003) ASP.NET带给我们很多惊喜,强大的Web Form控件自然是其中的重要部分。这其中,最受关注的当然是Datagrid。在ASP中用HTML标记语法来输出数据的方法在Datagrid数据绑定面前显得如

韩睿(Henry Han)的专栏 2345

Asp.net中DataGrid控件的自定义分页

         使用DataGrid时自带的分页实现起来虽然比较方便,但是效率不高,每次都需要读取所有页(整个记录集),而加载的只是其中一页,造成了资源的浪费,记录多又会使效率变得很低。下面通过DataGrid自定义分页功能来减少资源使用和提高效率。         实现的关键是设置AllowCustomPaging属性位True,并把VirtualItemCount属性设置位总的记录数,给分

星空传说BLOG 957

ASP.NET中利用DataGrid自定义分页功能和存储过程结合实现高效分页

             ASP.NET中利用DataGrid自定义分页功能和存储过程结合实现高效分页 ASP.Net中的DataGrid有内置分页功能, 但是它的默认的分页方式效率是很低的,特别是在数据量很大的时候,用它内置的分页功能几乎是不可能的事,因为它会把所有的数据从数据库读出来再进行分页, 这种只选取了一小部分而丢掉大部分的方法是不可去取的.在最进的一个项目中因为一个管理页

yzx110的专栏 1万+

南水北调线路图和影响区shp数据

GIS制图资源,南水北调中、东线线路和影响区shp格式示意图

上一篇: DataGrid资料
下一篇: 1. 打开新的窗口并传送参数:
bitm
博客等级 码龄23年 1粉丝 29原创
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值