当前位置: 首页 > 图文教程 > 网络编程 > ASP.NET > ASP.NET中的DataGrid的属性

ASP.NET
aspnet_regsql不能在sql2005下使用的解决
.NET发送邮件
让.Net验证控件与自定义验证合作无间
给.Net程序员和WEB程序员建议:.Net篇
给.Net程序员和WEB程序员建议:WEB篇
Server Application Unavailable错误解决方法
ASP.NET AJAX:UpdatePanel控件
ASP.NET教程:Ref和Out关键字异同
组件Newtonsoft.Json实现object2json转换
ASP.NET教程:Control基类清理页面状态
ASP.NET入门教程:认识ASP.NET
ASP.NET入门教程:ASP.NET和ASP区别
ASP.NET入门教程:简单的ASP.NET页面
ASP.NET入门教程:服务器控件
ASP.NET入门教程:事件句柄
ASP.NET入门教程:Web表单
ASP.NET入门教程:Web表单维持对象的ViewState
ASP.NET入门教程:TextBox控件
ASP.NET入门教程:Button控件
ASP.NET入门教程:数据绑定

ASP.NET中的DataGrid的属性


出处:互联网   整理: 软晨网(RuanChen.com)   发布: 2009-11-03   浏览: 206 ::
收藏到网摘: n/a

 ////////////////分页处理程序;
  
  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="Images\image1.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
   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"/>