Click here to Skip to main content
15,922,696 members
Please Sign up or sign in to vote.
4.00/5 (1 vote)
See more:
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[&quot;order2&quot;] = 0;
  }
  else
  {
      Session[&quot;order2&quot;] = 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...
Posted
Updated 28-Mar-11 12:18pm
v2
Comments
Wendelius 28-Mar-11 18:18pm    
Pre tags added

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900