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.GetMaterialsStorageCurrent(this.ddlMaterialType.SelectedValue); if (dtout == null) { this.SetErrorMsgPageBydir("查询出错,请重试!"); btnExcel.Enabled = false; return; } else { dtout.TableName = "原材料结存报表"; this.TableConvert(dtout, "原材料类型", "tbNameCodeToStorage", "vcCommSign='MaterialType'"); 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; } } UcPageView1.MyDataGrid.PageSize = 30; DataView dvOut = new DataView(dtout); this.UcPageView1.MyDataSource = dvOut; this.UcPageView1.BindGrid(); } catch (Exception er) { this.clog.WriteLine(er); this.SetErrorMsgPageBydir("查询错误,请重试!"); return; } }