protected void Btn_Insert_Click(object sender, EventArgs e) { try { if (this.hid_PageStatus.Value == "QUERY" || this.hid_PageStatus.Value == "VIEW" || this.hid_PageStatus.Value == "MODIFY") { int iPageIndex; DataTable Dt = (DataTable)Session["STM321_" + PageTimeStamp.Value]; if (Dt == null || Dt.Rows.Count == 0) { BCO.MaintainStoreHoliday bco = new BCO.MaintainStoreHoliday(ConntionDB); Dt = bco.QuerySchema(); } DataRow dRow = Dt.NewRow(); Dt.Rows.Add(dRow); Session["STM321_" + PageTimeStamp.Value] = Dt; if (Dt.Rows.Count > 0) { double dbTemp = Dt.Rows.Count / gv_Detail.PageSize; iPageIndex = Int32.Parse(Math.Truncate(dbTemp).ToString()); } else { iPageIndex = 0; } this.gv_Detail.PageIndex = iPageIndex; this.setGV((Dt.Rows.Count > gv_Detail.PageSize ? (Dt.Rows.Count - (gv_Detail.PageSize * gv_Detail.PageIndex) - 1) : Dt.Rows.Count - 1), Dt, true); SetGrigViewEditTab(Dt, (Dt.Rows.Count > gv_Detail.PageSize ? (Dt.Rows.Count - (gv_Detail.PageSize * gv_Detail.PageIndex) - 1) : Dt.Rows.Count - 1)); #region 存檔後狀態設定 this.hid_PageStatus.Value = "MODIFY"; this.txt_PageStatus.Text = "MODIFY"; #endregion } } catch (Exception ex) { ErrorMsgLabel.Text = ex.Message.Split(Environment.NewLine.Replace(Environment.NewLine, "~").ToCharArray())[0]; //直接取第一個 } finally { SetPageStatus(); } }