我在网络表单上的图表有问题。 我点击一个按钮显示图表时出现“undefined”错误。我的代码背后是... 我的图表显示在网络表单上有问题。 我点击一个按钮显示图表时出现“undefined”的错误。下面是我的代码...
public partial class Dashboard : System.Web.UI.Page
{
public ActionResult Index()
{
return View();
}
private ActionResult View()
{
return View();
}
// Using ADO.NET Code
public JsonResult ChartFunction()
{
string query = "select [Month],SalesCount from ProductSales";
string constring = @"Data Source=JOHN-PC;Initial Catalog=SmartCare_Melchizedek ;Integrated Security=True;";
List<ProductDetails> chartData = new List<ProductDetails>();
using (SqlConnection con = new SqlConnection(constring))
{
using (SqlCommand cmd = new SqlCommand(query))
{
cmd.CommandType = CommandType.Text;
cmd.Connection = con;
con.Open();
using (SqlDataReader dr = cmd.ExecuteReader())
{
while (dr.Read())
{
ProductDetails pd = new ProductDetails();
pd.Month = dr["Month"].ToString();
pd.SalesCount = Convert.ToInt32(dr["SalesCount"]);
chartData.Add(pd);
}
}
con.Close();
}
}
return Json(chartData, JsonRequestBehavior.AllowGet);
}
private JsonResult Json(List<ProductDetails> chartData, object allowGet)
{
return Json(chartData, JsonRequestBehavior.AllowGet);
}
class ProductDetails
{
public string Month { get; set; }
public Nullable<int> SalesCount { get; set; }
}
public class JsonRequestBehavior
{
public static object AllowGet { get; set; }
}
}