Im trying to get a chart on my view and I´m displaying it like this in my view:
<asp:Content ID="Content2" ContentPlaceHolderID="MainContent" runat="server">
<h2>ChartResult</h2>
<% using (Html.BeginForm("HandleChartType", "Chart")) %>
<% { %>
<%= Html.DropDownList("ListItems", "Select Chart Type")%>
<input type="submit" value="Set Chart" />
<%} %>
<% myChart.Controls.Add(ViewData["Chart"] as Chart); %>
<asp:Panel ID="myChart" runat="server"></asp:Panel>
<!--<img src="/Chart/CreateChart" alt="" />-->
<h2>FormResults</h2>
</asp:Content>
This line <% myChart.Controls.Add(ViewData["Chart"] as Chart); %> generates the error message OutputStream is not available when a custom TextWriter is used
This is the code from the controller:
public ActionResult ChartResult()
{
List<string> items = GetFilteredChartTypes();
ViewData["ListItems"] = new SelectList(items);
Chart myChart = CreateChart(SeriesChartType.Column);
ViewData["Chart"] = myChart;
return View();
}
The CreateChart function just creates a chart with Column as chart type. Why do I get this error, OutputStream is not available when a custom TextWriter is used?