回复 24楼elwin的帖子
1.不需要设置 IsTrackingViewState 属性 为 true。
2.楼主可以参考帮助文档中:Saving Data to the Session State 章节,下面是该节代码片段:
- protected void Page_Load(object sender, System.EventArgs e)
- {
- if (this.IsPostBack) return;
- // Connect to NWIND MS Access example with OLE DB.
- OleDbConnection thisConnection = new OleDbConnection("Provider=Microsoft.Jet.OLEDB.4.0; Data Source=D:\\NWIND.MDB");
- // Open connection.
- thisConnection.Open();
- // Create DataSet to contain related data tables, rows, and columns.
- DataSet thisDataSet = new DataSet();
- OleDbDataAdapter orderAdapter = new OleDbDataAdapter("SELECT * FROM Orders", thisConnection);
- orderAdapter.Fill(thisDataSet, "Orders");
- FpSpread1.ActiveSheetView.IsTrackingViewState = true;
- FpSpread1.ActiveSheetView.DataSource = thisDataSet;
- FpSpread1.ActiveSheetView.DataMember = "Orders";
- }
- protected void FpSpread1_SaveOrLoadSheetState(object sender, FarPoint.Web.Spread.SheetViewStateEventArgs e)
- {
- if (e.IsSave)
- {
- Session[e.SheetView.SheetName] = e.SheetView.SaveViewState();
- }
- else
- {
- e.SheetView.LoadViewState(Session[e.SheetView.SheetName]);
- }
- e.Handled = true;
- }
复制代码 |