我在代码隐藏文件中完全动态地生成图表并将图像保存为 jpeg 格式。
Chart Chart1 = new Chart();
Chart1.DataSource = ds.Tables[0];
Chart1.DataBind();
Chart1.Series.Add(new Series());
Chart1.Series[0].ChartType = System.Web.UI.DataVisualization.Charting.SeriesChartType.Pie;
Chart1.Series[0].XValueMember = "bloodType";
Chart1.Series[0].YValueMembers = "Total";
Chart1.ChartAreas.Add(new ChartArea());
Chart1.ChartAreas[0].Area3DStyle.Enable3D = true;
Chart1.ImageType = System.Web.UI.DataVisualization.Charting.ChartImageType.Jpeg;
Chart1.SaveImage("C:\\MyChartImage.jpg", ChartImageFormat.Jpeg);
HtmlTable tbProductImage = new HtmlTable();
HtmlTableRow trImageRow = new HtmlTableRow();
HtmlTableCell tdImageCell = new HtmlTableCell();
//Get generaqted image.
System.Web.UI.WebControls.Image imageVar = new System.Web.UI.WebControls.Image();
imageVar .Visible = true;
imageVar .ImageUrl = "C:\\MyChartImage.jpg";
tdImageCell.Controls.Add(imageVar );
trImageRow.Cells.Add(tdImageCell);
tbProductImage.Rows.Add(trImageRow);
this.Controls.Add(tbProductImage);
图表图像在 C:\ 驱动器中成功生成,但是当我尝试将其放入 HTMl 表格单元格时,没有呈现任何内容。没有显示错误。如何显示图像?请帮忙。