private void btnQuery_Click(object sender, System.EventArgs e) { Session.Remove("QUERY"); Hashtable htapp = (Hashtable)Application["appconf"]; string strcons = (string)htapp["cons"]; msb1 = new MaterialSBusi(strcons); try { DataTable dtout = msb1.GetMaterialsSimpleAnalyse(this.ddlMaterialType.SelectedValue, this.ddlMonth.SelectedValue); if (dtout == null) { this.SetErrorMsgPageBydir("查询出错,请重试!"); btnExcel.Enabled = false; return; } else { dtout.TableName = "原材料分析报表"; DataTable dtexcel = dtout.Copy(); Session["QUERY"] = dtout; // for(int i=0;i<dtexcel.Rows.Count;i++) // { // dtexcel.Rows[i][0]="'"+dtexcel.Rows[i][0].ToString(); // } Session["toExcel"] = dtexcel; if (dtout.Rows.Count <= 0) { btnExcel.Enabled = false; } else { btnExcel.Enabled = true; } } upPager = true; this.DataGrid1.DataSource = dtout; this.DataGrid1.DataBind(); } catch (Exception er) { this.clog.WriteLine(er); this.SetErrorMsgPageBydir("查询错误,请重试!"); return; } }