ASP.NET里的DataGrid的属性

分类: asp.net   出处:iocblog整理  更新时间:2009-03-25   添加到收藏  

 ////////////////分页处理程序;
  
  void page_load(object sender, eventargs e)
   {
  
   if (checkbox1.checked)
   itemsgrid.pagerstyle.mode=pagermode.numericpages;
   else
   itemsgrid.pagerstyle.mode=pagermode.nextprev;
  
   if (!ispostback)
   {
   start_index = 0;
   itemsgrid.virtualitemcount=100;
   }
  
   bindgrid();
  
   }
  
  /////////////邦定公用函数;
  
   void bindgrid()
   {
  
   itemsgrid.datasource=createdatasource();
   itemsgrid.databind();
  
   }
  
   ///////////////////////// 数据库的链 接在前面已经发表过的,!
   <asp:datagrid id="itemsgrid" runat="server"
   bordercolor="black"
   borderwidth="1"
   cellpadding="3" //行间隔;
   allowpaging="true" //换页开关;
   allowcustompaging="true" //
   backimageurl="imagesimage1.jpg" //背景图象;
   autogeneratecolumns="false" //改变属性数据格会不一样有:true & false;
   onpageindexchanged="grid_change"> //分页驱动程序id
  //分页默认样式;
   <pagerstyle nextpagetext="forward"
   prevpagetext="back"
   position="bottom"
   pagebuttoncount="5"
   backcolor="#00aaaa">
   </pagerstyle>
  
   <alternatingitemstyle backcolor="yellow">
   </alternatingitemstyle>
  
   <headerstyle backcolor="#00aaaa">
   </headerstyle>
  
   <columns>
  
   <asp:boundcolumn headertext="number"
   datafield="integervalue"/>
  
   <asp:boundcolumn (来源 www.iocblog.net)
   headertext="item"
   datafield="stringvalue"/>
  
   <asp:boundcolumn
   headertext="price"
   datafield="currencyvalue"
   dataformatstring="{0:c}">
  
   <itemstyle horizontalalign="right">
   </itemstyle>
  
   </asp:boundcolumn>
  
   </columns>
  
   </asp:datagrid>
  
   <br>
  //选择数字显示分页
   <asp:checkbox id="checkbox1"
   text = "show page navigation"
   autopostback="true"
   runat="server"/>(来源 www.iocblog.net)


Tag: DataGrid



文章整理:iocblog
版权申明:本站文章均来自网络,如有侵权,请联系我们,我们收到后立即删除,谢谢!
特别注意:本站所有转载文章言论不代表本站观点,本站所提供的摄影照片,插画,设计作品,如需使用,请与原作者联系,版权归原作者所有。