請教各位大大們:
以下是我的程式碼,希望在按下按鈕後按鈕先無效,執行完後再變有效(為防止重覆按鈕)
測試過有Report.ExportToHttpResponse(ExportFormatType.PortableDocFormat, Response, true, "CR_" + TB_ID.Text);此行則對所有控制項的設定都無效,拿掉就正常.
protected void BN_查詢_Click(object sender, EventArgs e)
{
BN_查詢.Enabled = false;
Label1.Text = "";
Label2.Text = "";
CheckErr = "";
StrSql = "";
if (TB_ID.Text == "") { CheckErr += "★未輸入" + LB_ID.Text.Substring(0, 4) + "!"; }
else
{
TextBox TBName = TB_GetVal;
StrSql = "SELECT COUNT(詢案編號) as 筆數 FROM dbo." + DDL_RtName.SelectedItem.Text + " WHERE 詢案編號 = '" + TB_ID.Text + "'";
GetValue.GetInt(TBName, StrSql, Session["u_conn"].ToString());
if (Convert.ToInt32(TB_GetVal.Text) == 0) { CheckErr += "★找不到" + LB_ID.Text + TB_ID.Text + "!"; }
}
if (CheckErr == "")
{
Label1.Text = "表單下載中...請稍候";
DataSet ds = new DataSet();
using (SqlConnection Conn = new SqlConnection(WebConfigurationManager.ConnectionStrings[Session["u_conn"].ToString()].ConnectionString))
{
SqlDataAdapter myAdapter = new SqlDataAdapter("Select * From dbo." + DDL_RtName.SelectedItem.Text + " WHERE 詢案編號 = '" + TB_ID.Text + "'", Conn);
myAdapter.Fill(ds, DDL_RtName.SelectedItem.Text);
if (DDL_RtName.SelectedItem.Text == "D非整梯估價資訊表")
{
SqlDataAdapter myAdapter1 = new SqlDataAdapter("Select * From dbo.D非整梯估價項目表 WHERE 詢案編號 = '" + TB_ID.Text + "'", Conn);
myAdapter1.Fill(ds, "D非整梯估價項目表");
}
}
ReportDocument Report = new ReportDocument();
Report.Load(Server.MapPath("Reports/CR_" + DDL_RtName.SelectedItem.Text + ".rpt"));
Report.SetDataSource(ds);
Report.SetParameterValue("UserName", Session["u_username"].ToString());
//下一行是問題根源
Report.ExportToHttpResponse(ExportFormatType.PortableDocFormat, Response, true, "CR_" + TB_ID.Text);
}
else { Label2.Text = CheckErr; }
BN_查詢.Enabled = true;
}