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

ASP.NET
c# Random快速连续产生相同随机数的解决方案
form身份验证通过后,只能用FormsAuthentication.RedirectFromLoginPage
ASP.NET Global.asax应用程序文件简介
Asp.net下载功能的解决方案代码
asp.net 生成数字和字母组合的随机数
asp.net显示页面执行时间
DiscuzNT 论坛与主站的同步登录与退出
c# 读取Northwind数据库image字段
asp.net 数据访问层基类
C# 文件保存到数据库中或者从数据库中读取文件
ASP.NET 防止用户跳过登陆界面
asp.net 字符串加密解密技术
asp.net 票据简单应用
基于C# 网站地图制作
asp.net GridView 中增加记录的方法
asp.net 自动将汉字转换成拼音第一个字母
运行asp.net时出现 http错误404-文件或目录未找到
System.Runtime.InteropServices.COMException的解决方法
VS2005 180天限制破解方法
asp.net 面试+笔试题目

ASP.NET中的DataGrid的属性


出处:互联网   整理: 软晨网(RuanChen.com)   发布: 2009-11-03   浏览: 256 ::
收藏到网摘: 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"/>