|
楼主 |
发表于 2020-6-21 21:30:01
|
显示全部楼层
好呀,請幫忙。修改文本
protected System.Web.UI.WebControls.Button btnChangeText;
protected CrystalDecisions.Web.CrystalReportViewer cRV;
myReport ReportDoc = new myReport();
private void Page_Load(object sender, System.EventArgs e)
{
// 在此处放置用户代码以初始化页面
string strProvider = "Server=(local);DataBase=Northwind;UID=sa;PWD=111";
SqlConnection MyConn = new SqlConnection(strProvider);
MyConn.Open();
string strSelOrders = "Select * from orders";
string strSelOrdersDetails = "Select * from [Order Details]";
SqlDataAdapter daOrder = new SqlDataAdapter(strSelOrders,MyConn);
SqlDataAdapter daOrderDetails = new SqlDataAdapter(strSelOrdersDetails,MyConn);
DataSet ds = new DataSet();
daOrder.Fill(ds,"orders");
daOrderDetails.Fill(ds,"Order Details");
ReportDoc.SetDataSource(ds);
cRV.ReportSource = ReportDoc;
}
private void btnChangeText_Click(object sender, System.EventArgs e)
{
TextObject tb = (TextObject )ReportDoc.ReportDefinition.ReportObjects["Text2"];
tb.Text = "订单号";
}
装载
protected CrystalDecisions.Web.CrystalReportViewer CrystalReportViewer1;
protected System.Web.UI.WebControls.Button btnLoad;
protected System.Web.UI.HtmlControls.HtmlInputFile File1;
private void Page_Load(object sender, System.EventArgs e)
{
// 在此处放置用户代码以初始化页面
if(Session["filename"]!=null)
CrystalReportViewer1.ReportSource = Session["filename"].ToString();
}
private void btnLoad_Click(object sender, System.EventArgs e)
{
string strName = File1.PostedFile.FileName;
if(strName.Trim()!="")
{
CrystalReportViewer1.ReportSource = strName;
Session["filename"] = strName;
}
}
|
|