Re: [問題] DATAGRID分頁的問題..

看板C_Sharp (C#)作者 (( ′ 3`)y--~￾ ￾ N)時間19年前 (2006/03/20 12:12), 編輯推噓0(000)
留言0則, 0人參與, 最新討論串4/6 (看更多)
感謝各位高手幫小弟我解答.. 可是我有試過了還是一樣的錯誤.. 所以我想把我的程式貼上來看是不是我漏了哪些地方... 以下是我大概的程式..覺得太長的可以先跳到別篇.. using System; using System.Collections; using System.ComponentModel; using System.Data; using System.Data.OleDb; using System.Drawing; using System.Web; using System.Web.SessionState; using System.Web.UI; using System.Web.UI.WebControls; using System.Web.UI.HtmlControls; namespace TestADODotNET { public class TestTableSelectForm : System.Web.UI.Page { protected System.Web.UI.WebControls.DataGrid dgData; protected System.Web.UI.WebControls.Button Button1; protected System.Web.UI.WebControls.DropDownList dlname; private void Page_Load(object sender, System.EventArgs e) { if(!this.IsPostBack) { Bind_Data(); } else { } #region Web Form 設計工具產生的程式碼 override protected void OnInit(EventArgs e) { InitializeComponent(); base.OnInit(e); } private void InitializeComponent() { this.Button1.Click += new System.EventHandler(this.Button1_Click); this.Load += new System.EventHandler(this.Page_Load) this.dlname.SelectedIndexChanged += new System.EventHandler(this.dlname_SelectedIndexChanged) this.dgData.PageIndexChanged += new DataGridPageChangedEventHandler(dgData_PageIndexChanged); } #endregion protected void Bind_Data() { 裡面就是連到資料庫的一些資料 } void dlname_SelectedIndexChanged(object sender, System.EventArgs e) { this.lblMessage.Text = this.dlname.SelectedValue; Bind_Data(); } void dgData_PageIndexChanged(object sender, System.Web.UI.WebControls. DataGridPageChangedEventArgs e) { dgData.CurrentPageIndex = e.NewPageIndex; Bind_Data(); } 我的程式大概就是這樣... 試了幾次出現下面幾種情況.. 第一種: 在DATAGRID的屬性AllowPaging=True,AllowCustomPaging=False 沒有設定OnPageIndexChanged 會出現 [AllowCustomPaging 必須為 true, 且當 AllowPaging 設為 'true' 且所選取的資料來源沒有實作 ICollection 時, 必須為 ID 為 dgData 的 DataGrid 設定 VirtualItemCount]的錯誤 第二種: AllowPaging=True,AllowCustomPaging=True 沒有設定OnPageIndexChanged 就是可以正常出現..但是下面只出現 < > 圖案,但是這兩個圖案都不能點選, 不能切換到下一頁.. 第三種 只要有設定OnPageIndexChanged就會出現 因為保護層級,無法存取 'TestADODotNET.TestTableSelectForm.dgData_PageIndexChanged(object, System.Web.UI.WebControls.DataGridPageChangedEventArgs)' 的錯誤... 所以不知道是不是我有哪裡有錯誤沒看到... 希望可以各位高手可以有點耐心看完我的打的這篇.. 拜託幫幫我吧... 多謝... -- ※ 發信站: 批踢踢實業坊(ptt.cc) ◆ From: 140.127.114.219
文章代碼(AID): #147Yl5rE (C_Sharp)
文章代碼(AID): #147Yl5rE (C_Sharp)