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

ASP.NET
用 Asp.Net 建立一个在线 RSS 新闻聚合器的方法
关于前台调用后台事件__doPostBack函数
Bin 和 App_Code 文件夹介绍
.NET 2.0 的压缩功能代码
解决Visual Studio 2005 无法显示设计视图的方法
asp.net(c#)两种随机数的算法,可用抽考题
asp.net下url传递中文的解决方案
XmlReader 读取器读取内存流 MemoryStream 的注意事项
asp.net下创建、查询、修改带名称空间的 XML 文件的例子
使用.NET存储XML数据的方法
XslTransform.Transform将结果输出到字符串里的方法
安装 VS2005 SP1 有关问题的解决办法
asp.net下中文验证码,免费开源代码
自定义应用程序配置文件(app.config)
asp.net下使用DIME协议上传文件
动态改变ASP.net页面标题和动态指定页面样式表的方法
WEB上调用HttpWebRequest奇怪问题的解决方法
HTTP协议下用Web Service上传大文件的解决方案
asp.net下Response.ContentType类型汇总
ASP.NET User Control使用技巧一则

ASP.NET中的DataGrid的属性


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