}//ButtonQuery_Click private void databind() { //抓取本頁初次登記的時間 string SessionIDName = "POP_CGDVENDOR_" + PageTimeStamp.Value; CGDModel.CGD32_BCO BCO = new CGDModel.CGD32_BCO(ConntionDB); ParameterList.Clear(); ParameterList.Add(DBNull.Value); ParameterList.Add(DBPara("%" + txtVENDOR.Text.Trim() + "%", ParaType.Varchar2)); ParameterList.Add(DBPara("%" + txtVENDOR_NAME.Text.Trim() + "%", ParaType.Varchar2)); ParameterList.Add(DBPara(TextBoxRowCountLimit.Text.Trim(), ParaType.Number)); DataTable Dt = BCO.DoQuerySLP(ParameterList); Session[SessionIDName] = Dt; GridView1.DataSource = Dt; //設定分頁大小 if (TextBoxPagesize.Text == "0") { GridView1.PageSize = 1; } else { GridView1.PageSize = (TextBoxPagesize.Text == "") ? 10 : (int.Parse(TextBoxPagesize.Text) < 0) ? 10 : int.Parse(TextBoxPagesize.Text); } GridView1.PageIndex = 0; GridView1.DataBind(); GridView1.SelectedIndex = -1; }//databind
protected void GridView1_SelectedIndexChanging(object sender, GridViewSelectEventArgs e) { string SessionIDName = "POP_CGDVENDOR_" + PageTimeStamp.Value; CGDModel.CGD32_BCO BCO = new CGDModel.CGD32_BCO(ConntionDB); ParameterList.Clear(); ParameterList.Add(DBNull.Value); ParameterList.Add(DBPara("%" + txtVENDOR.Text.Trim() + "%", ParaType.Varchar2)); ParameterList.Add(DBPara("%" + txtVENDOR_NAME.Text.Trim() + "%", ParaType.Varchar2)); ParameterList.Add(DBPara(TextBoxRowCountLimit.Text.Trim(), ParaType.Number)); DataTable dt = BCO.DoQuerySLP(ParameterList); DataRow[] drs = dt.Select(string.Format("ID='{0}'", GridView1.DataKeys[e.NewSelectedIndex].Value)); if (drs.Length > 0) { DataRow dr = drs[0]; this.lblVENDOR.Text = dr["VENDOR"].ToString(); this.lblVENDOR_NAME.Text = dr["VENDOR_NAME"].ToString(); } }//GridView1_SelectedIndexChanging