private void SelectAll() { //新程式 string SessionIDName = string.Format("{0}_{1}", PAGE_DT_01, PageTimeStamp.Value); ErrorMsgLabel.Text = ""; try { VGRModel.MaintainReturnData BCOIVM = new VGRModel.MaintainReturnData(ConnectionDB); dtClassAndItemSelected = BCOIVM.GetStockByVendor(Vendor, SLP_RootNo.Text, LocateSection); Session[SessionIDName] = dtClassAndItemSelected; GridView1.DataSource = dtClassAndItemSelected; GridView1.PageSize = 20; //GridView1.PageSize = (TextBoxPagesize.Text == "") ? 10 : (int.Parse(TextBoxPagesize.Text) < 0) ? 10 : int.Parse(TextBoxPagesize.Text); GridView1.PageIndex = 0; GridView1.DataBind(); GridView1.SelectedIndex = -1; if (dtClassAndItemSelected == null || (dtClassAndItemSelected != null && dtClassAndItemSelected.Rows.Count <= 0)) { ScriptManager.RegisterStartupScript(UpdatePanel1, this.GetType(), "ClientScript", "alert('查無資料');", true); return; } for (int i = 0; i < GridView1.Rows.Count; i++) { CheckBox chk_Sgl = (CheckBox)GridView1.Rows[i].FindControl("chk_Sgl"); chk_Sgl.Checked = true; } CheckBox chbAll = (CheckBox)GridView1.HeaderRow.FindControl("chbAll"); chbAll.Checked = true; } catch (Exception ex) { ErrorMsgLabel.Text = ex.ToString(); } }