打印本文 打印本文 关闭窗口 关闭窗口
asp.net中显示DataGrid控件列序号的几种方法
作者:武汉SEO闵涛  文章来源:敏韬网  点击数3693  更新时间:2009/4/23 10:46:04  文章录入:mintao  责任编辑:mintao
bsp;         if(!Page.IsPostBack)

              {

                   DataGridDataBind();

              }

         }

 

         //绑定数据

         private void DataGridDataBind()

         {

              DataSet ds = DataAccess.GetCustomersData();

              this.DataGrid1.DataSource = ds;

              this.DataGrid1.DataBind();

         }

 

        

 

         #region Web 窗体设计器生成的代码

         override protected void OnInit(EventArgs e)

         {

              InitializeComponent();

              base.OnInit(e);

         }

        

         /// <summary>

         /// 设计器支持所需的方法 - 不要使用代码编辑器修改

         /// 此方法的内容。

         /// </summary>

         private void InitializeComponent()

         {   

              this.DataGrid1.ItemCreated += new System.Web.UI.WebControls.DataGridItemEventHandler(this.DataGrid1_ItemCreated);

              this.DataGrid1.PageIndexChanged += new System.Web.UI.WebControls.DataGridPageChangedEventHandler(this.DataGrid1_PageIndexChanged);

              this.DataGrid1.ItemDataBound += new System.Web.UI.WebControls.DataGridItemEventHandler(this.DataGrid1_ItemDataBound);

              this.Load += new System.EventHandler(this.Page_Load);

 

         }

         #endregion

 

         //翻页

         private void DataGrid1_PageIndexChanged(object source, System.Web.UI.WebControls.DataGridPageChangedEventArgs e)

         {

              DataGrid1.CurrentPageIndex = e.NewPageIndex;

              DataGridDataBind();

         }

         //获取当前项

         protected int GetRecordIndex(int itemIndex)

         {

              return (DataGrid1.CurrentPageIndex * DataGrid1.PageSize + itemIndex + 1);

         }

                   private void DataGrid1_ItemCreated(object sender, System.Web.UI.WebControls.DataGridItemEventArgs e)

         {

上一页  [1] [2] [3] [4] [5]  下一页

打印本文 打印本文 关闭窗口 关闭窗口