DATAGRID的集中功能!!(代码页)[1]

[入库:2005年8月18日] [更新:2007年3月24日]

本文简介:选择自 sichuanpb 的 blog

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;
using system.data.oledb;


namespace ygdzwww
{
 /// <summary>
 /// webform1 的摘要说明。
 /// </summary>
 public class webform1 : system.web.ui.page
 {
  protected system.web.ui.webcontrols.datagrid datagrid1;
  protected system.web.ui.webcontrols.label label4;
  protected system.web.ui.webcontrols.linkbutton pagefirst;
  protected system.web.ui.webcontrols.linkbutton pagenext;
  protected system.web.ui.webcontrols.linkbutton pagelast;
  protected system.web.ui.webcontrols.linkbutton pagepre;
  protected system.web.ui.webcontrols.button btxiandelete;
  protected system.web.ui.webcontrols.button btxiansearch;
  protected system.web.ui.webcontrols.label lbxianname;
  protected system.web.ui.webcontrols.textbox tbxianname;
  protected system.web.ui.webcontrols.label lbpagecount;
  protected system.web.ui.webcontrols.button btxianadd;
 
  private void page_load(object sender, system.eventargs e)
  {
   // 在此处放置用户代码以初始化页面
   if(!page.ispostback)
   {
    datagrid1.datasource=new ygdz.wkr_t01_01_1service().getall();
    datagrid1.databind();
    lbpagecount.text = "第"+((int32) datagrid1.currentpageindex +1)+"页"+"/共"+datagrid1.pagecount +"页";
   }
  }

  #region web 窗体设计器生成的代码
  override protected void oninit(eventargs e)
  {
   //
   // codegen: 该调用是 asp.net web 窗体设计器所必需的。
   //
   initializecomponent();
   base.oninit(e);
  }
  
  /// <summary>
  /// 设计器支持所需的方法 - 不要使用代码编辑器修改
  /// 此方法的内容。
  /// </summary>
  private void initializecomponent()
  {   
   this.btxianadd.click += new system.eventhandler(this.btxianadd_click);
   this.btxiandelete.click += new system.eventhandler(this.btxiandelete_click);
   this.btxiansearch.click += new system.eventhandler(this.btxiansearch_click);
   this.load += new system.eventhandler(this.page_load);

  }
  #endregion

  private void btxianadd_click(object sender, system.eventargs e)
  {
   response.redirect("ygdz_xianadd.aspx" );   
  }
  

  public void pagebutton(object sender, system.eventargs e)
  {
   string arg=((linkbutton)sender).commandargument;
   switch(arg)
   {
    case ("pagefirst"):
     datagrid1.currentpageindex=0;
     break;
    case ("pagenext"):
     if(datagrid1.currentpageindex<(datagrid1.pagecount -1))
      datagrid1.currentpageindex ++;
     break;
    case ("pagepre"):
     if(datagrid1.currentpageindex>0)
      datagrid1.currentpageindex --;
     break;
    case ("pagelast"):
     datagrid1.currentpageindex=datagrid1.pagecount-1;
     break;

   }
   datagrid1.datasource=new ygdz.wkr_t01_01_1service().getall();
   datagrid1.databind();
   lbpagecount.text="第"+((int32) datagrid1.currentpageindex +1)+"页"+"/共"+datagrid1.pagecount +"页";

  
  }

本文关键:DATAGRID的集中功能!!(代码页)
  相关方案
Google
 

本站最佳浏览方式为 分辨率 1024x768 IE 6.0(或更高版本的 IE浏览器)

go top