this gives me headache...-_-..
I have a view ..
foreach(var product in Model)
{
....
<% Html.RenderAction("GetChartData", "Inventory", new { productId = product.ProductID}); %>
<% Html.RenderPartial("ChartView");%>
....
}
in "
GetChartData
" method which is in controller..
I set data in sessions..
for example..
if (order1.ToList().Count() == 0)
{
Session["order1"] = 0;
}
else
{
Session["order1"] = order1.ToList()[0].Qty;
}
if (order2.ToList().Count() == 0)
{
Session["order2"] = 0;
}
else
{
Session["order2"] = order2.ToList()[0].Qty;
}
.......
and on "ChartView" usercontrol..
System.Web.UI.DataVisualization.Charting.Chart Chart2 = new System.Web.UI.DataVisualization.Charting.Chart();
Chart2.Width = 500;
Chart2.Height = 300;
Chart2.RenderType = RenderType.ImageTag;
Chart2.ImageStorageMode = ImageStorageMode.UseImageLocation;
Chart2.ImageLocation = "~/temp";
Chart2.Palette = ChartColorPalette.BrightPastel;
Title t = new Title("Sold Qty In Weeks", Docking.Top, new System.Drawing.Font("Trebuchet MS", 7, System.Drawing.FontStyle.Bold), System.Drawing.Color.FromArgb(26, 59, 105));
Chart2.Titles.Add(t);
Chart2.ChartAreas.Add("Series 1");
Chart2.Series.Add("Series 1");
Chart2.Series["Series 1"].ChartType = SeriesChartType.FastLine;
Chart2.Series["Series 1"].Points.AddY(Convert.ToInt32(Session["order1"]));
Chart2.Series["Series 1"].Points.AddY(Convert.ToInt32(Session["order2"]));
Chart2.Series["Series 1"].Points.AddY(Convert.ToInt32(Session["order3"]));
..........
Chart2.Page = this.Page;
HtmlTextWriter writer = new HtmlTextWriter(Page.Response.Output);
Chart2.RenderControl(writer);
Chart2.Dispose();
then when I load page.. I get all the same chart for each row. i think may be the last chart is overlapping all the previous charts.
when I debug, I am pretty sure that I get different values for each product.
I don't understand why this happens..
please help...