AspNetPager分页控件--使用方法11

时间:2010-01-29 13:28:19  来源:第二电脑网  作者:第二电脑网

  第二电脑网导读:'Padding-Top','2px');   writer.AddStyleAttribute('Padding-Bottom',2px');   writer.AddStyleAttribute('Width',width.ToString());   writer.AddStyleAttribute('Height',Height.ToString());   base.AddAttributesToRender(writer);   }   protected virtual void OnPageChangeCl...
  正文: //定义Div的样式
  protected override void AddAttributesToRender(HtmlTextWriter writer)
  {
  writer.AddStyleAttribute('White-space','nowrap');
  writer.AddStyleAttribute('Padding-Top','2px');
  writer.AddStyleAttribute('Padding-Bottom',2px');
  writer.AddStyleAttribute('Width',width.ToString());
  writer.AddStyleAttribute('Height',Height.ToString());
  base.AddAttributesToRender(writer);
  }
  protected virtual void OnPageChangeClick(EventArgs e)
  {
  if(ChangePageClick!=null)
  {
  ChangePageClick(this,e);
  }
  } public void RaisePostBackEvent(string eventArgument)
  {
  int PageIndex=int.Parse(eventArgument);
  this._CurrentPageIndex=PageIndex;
  OnPageChangeClick(new EventArgs());
  }
  ///<summary>
  ///将此控件呈现给指定的输出参数
  ///</summary>
  ///<param name='output'>要写出到的HTML编写器</param>
  protected override void RenderContents(HtmlTextWriter output)
  {this._TotalPage=((this.TotalRecord/PageSize)*this.PageSize==this.TotalRecord)?(this.TotalRecord/this.PageSize):((this.TotalRecord/this.PageSize)+1);
  int BeginRecord=(this.CurrentPageIndex-1)*this.PageSize+1;
  int EndRecord=this.CurrentPageIndex*this.PageSize;
  String PageInfo='[共<font color=#CC0000>'+this.TotalPage.ToString()+'</font>页/当前第<font color=#CC0000>'+this.CurrentPageIndex.ToString()+'</font>页共<font color=#CC0000>'+TotalRecord.ToString()+'</font>条记录,当前记录数< font color=#CC0000>'+BegingRecord.ToString()+'</font>到<font color=#CC0000>'+EndRecord.ToString()+'</font>]';
  string PageListStr='';
  string PageIndexColor='#0000C0';
  int SingleNumber=this.TotalPage-(TotalPage/ItemSize)*ItemSize; //得到分页后的尾数(比如:总共58页,按10页规格显示,则尾数为8)
  int IntPageForMax=(this.CurrentPageIndex-1)/ItemSize;
  int MinInt=(1+ItemSize*IntPageForMax);
  int MaxInt=((IntPageForMax+1)*ItemSize)>TotalPage?TotalPage:((IntPageForMax+1)*ItemSize);
  if(this.TotalRecord==0||this.TotalPage==0)
  {
  PageListStr='<font color='+PageIndexColor+'>0</font>';
  PageListStr =PageListStr+'[共<font color=#CC0000>0</font>页/当前第<font color=#CC0000>0</font>页 共<font color=#CC0000>0</font>条记录,当前记录数<font color=#CC0000>0</font>到<font color=#CC0000>0</font>]';
  output.Write(PageListStr);
  }
  else
  {
  if(this.TotalPage<=this.ItemSize)
  {
  for(int i=1;i<=TotalPage;i++)
  {
  PageIndexColor=CurrentPageIndex==i?'#CC0000':'#0000C0';
  if(CurrentPageIndex==i)
  PageListStr=PageListStr+'<a title='当前为第['+i+']页' href='#' id=''+this.UniqueID+''><font color='+PageIndexColor+'>'+i.ToString()+'</font></a>';
  else
  PageListStr=PageListStr+'<a title='点击转到第['+i+']页' id=''+this.UniqueID+'' href=' JavaScript:'+Page.GetPostBackEventReference(this,i.ToString())+''><font color='+PageIndexColor+'>'+i.ToString()+'</font></a>';
  }
  PageListStr=PageListStr==''?'<font color='+PageIndexColor+'>0</font>':PageListStr; 《AspNetPager分页控件--使用方法11》由第二电脑网原创提供,转载请注明:http://www.002pc.com/master/College/Programming/aspnet/12593.html


关键字:

关于《AspNetPager分页控件--使用方法11》文章的评论

站内搜索: 高级搜索

热门搜索: Windows style 系统 tr IP QQ CPU 安装 function 注册 if td