I Want to bind my products table data to graph from sql server database
but I got the error as "Specified Method is Not Suported",
below is my code,
public class Default1Controller : Controller
{
private DummyEntities db = new DummyEntities();
// GET: /Default1/
public ActionResult Index()
{
var b = db.Products;
var chart = new Chart(width: 400, height: 200, theme: ChartTheme.Blue)
.AddTitle("Products")
.AddSeries(chartType: "pie")
.DataBindTable(dataSource: b, xField: "ProductName");
chandana G
Member
7 Points
69 Posts
How to bind data to graphs in asp.net mvc3
May 04, 2012 07:13 AM|LINK
Hi to All,
I Want to bind my products table data to graph from sql server database
but I got the error as "Specified Method is Not Suported",
below is my code,
public class Default1Controller : Controller
{
private DummyEntities db = new DummyEntities();
// GET: /Default1/
public ActionResult Index()
{
var b = db.Products;
var chart = new Chart(width: 400, height: 200, theme: ChartTheme.Blue)
.AddTitle("Products")
.AddSeries(chartType: "pie")
.DataBindTable(dataSource: b, xField: "ProductName");
this.ViewBag.Chart = chart;
return View();
}
view:
<%@ Page Title="" Language="C#" MasterPageFile="~/Views/Shared/Site.Master" Inherits="System.Web.Mvc.ViewPage<MvcApplication17.Product>" %>
<asp:Content ID="Content1" ContentPlaceHolderID="TitleContent" runat="server">
Index
</asp:Content>
<asp:Content ID="Content2" ContentPlaceHolderID="MainContent" runat="server">
<%:ViewBag.Chart.Write() %>
<h2>Index</h2>
</asp:Content>
If anyone know the solution please send
asp.netmvc3
ignatandrei
All-Star
134491 Points
21566 Posts
Moderator
MVP
Re: How to bind data to graphs in asp.net mvc3
May 04, 2012 07:21 AM|LINK
I think that this is the line:
Why not put just
<%:ViewBag.Chart %>
asp.netmvc3
tusharrs
Contributor
3230 Points
668 Posts
Re: How to bind data to graphs in asp.net mvc3
May 04, 2012 07:24 AM|LINK
try this
asp.netmvc3
( Mark as Answer if it helps you out )
View my Blog
teguhyuliant...
Participant
1370 Points
372 Posts
Re: How to bind data to graphs in asp.net mvc3
May 04, 2012 07:28 AM|LINK
Hi,
could you please refer this link, maybe can solve your problem
http://msdn.microsoft.com/en-us/library/dd489231.aspx
asp.netmvc3
chandana G
Member
7 Points
69 Posts
Re: How to bind data to graphs in asp.net mvc3
May 04, 2012 08:33 AM|LINK
but output as
System.Web.Helpers.Chart only,
nothing is displayed on the screen
asp.netmvc3