}//databind

    protected void GridView1_SelectedIndexChanging(object sender, GridViewSelectEventArgs e)
    {
        string SessionIDName = "POP_OutVendorBase_" + PageTimeStamp.Value;
        VDMModel.OUT02 BCO = new VDMModel.OUT02(ConntionDB);
        //DataTable dt = (DataTable)Session[SessionIDName];

        ParameterList.Clear();
        ParameterList.Add(txtVENDOR_ST.Text.Trim());
        ParameterList.Add(txtVENDOR_ED.Text.Trim());
        ParameterList.Add(SLP_VENDOR_OPEN_DATE.StartDate);
        ParameterList.Add(SLP_VENDOR_OPEN_DATE.EndDate);
        ParameterList.Add(SLP_VENDOR_CLOSE_DATE.StartDate);
        ParameterList.Add(SLP_VENDOR_CLOSE_DATE.EndDate);
        ParameterList.Add(""); // vendor_name
        ParameterList.Add(TextBoxRowCountLimit.Text.Trim());

        DataTable dt = BCO.QueryByLikeForSLP(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
    protected void ButtonQuery_Click(object sender, EventArgs e)
    {
        try
        {
            //清除目前選擇DATA
            this.lblVENDOR.Text = "";
            this.lblVENDOR_NAME.Text = "";

            VDMModel.OUT02 bco = new VDMModel.OUT02(ConntionDB);
            firstpage = 0;
            firstindex = -1;

            databind();
        }
        catch (Exception ex)
        {
            ErrorMsgLabel.Text = ex.Message;
        }
        finally { }
    }//ButtonQuery_Click
    }//ButtonQuery_Click

    private void databind()
    {
        string strVendorName = txtVendorName.Text.Trim().Replace("'", "''");
        if (strVendorName != "")
        {
            strVendorName = "%" + strVendorName + "%";
        }
        //抓取本頁初次登記的時間
        string SessionIDName = "POP_OutVendorBase_" + PageTimeStamp.Value;
        VDMModel.OUT02 BCO = new VDMModel.OUT02(ConntionDB);

        ParameterList.Clear();
        ParameterList.Add(txtVENDOR_ST.Text.Trim());
        ParameterList.Add(txtVENDOR_ED.Text.Trim());
        ParameterList.Add(SLP_VENDOR_OPEN_DATE.StartDate);
        ParameterList.Add(SLP_VENDOR_OPEN_DATE.EndDate);
        ParameterList.Add(SLP_VENDOR_CLOSE_DATE.StartDate);
        ParameterList.Add(SLP_VENDOR_CLOSE_DATE.EndDate);
        ParameterList.Add(strVendorName);
        ParameterList.Add(TextBoxRowCountLimit.Text.Trim());

        DataTable Dt = BCO.QueryByLikeForSLP(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