private void Button1_Click(object sender, System.EventArgs e) { Session.Remove("QUERY"); Session.Remove("toExcel"); Hashtable htapp = (Hashtable)Application["appconf"]; string strcons = (string)htapp["cons"]; msb1 = new MaterialSBusi(strcons); string strMaterialCode = txtMaterialCode.Text.Trim(); string strMaterialName = txtMaterialName.Text.Trim(); string strMaterialType = ddlMaterialType.SelectedValue; string strBatchNo = txtBatchNo.Text.Trim(); try { DataTable dtout = msb1.GetMaterials(strMaterialCode, strMaterialName, strMaterialType, strBatchNo); 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(); // } dtexcel.Columns.Remove("操作"); 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; } }