I am using the same concept to create a web method in a web service and calling those methods in jQuery.
Step 1
Create a table as in the following:
- CREATE TABLE tblRevenue (
- Id int Primary Key IDENTITY(1,1) NOT NULL,
- amount bigint NULL,
- quarter varchar(4) NULL,
- year varchar(4) NULL,
- )
After completion of table design, enter some of the test data into table to work for our sample
We will now create a web method in the web service and use that method to call it from jQuery.
Step 2
Create an ASP.NET Web Service. Add an .asmx page to the current solution and modify the code as in the following example:
- using System;
- using System.Collections.Generic;
- using System.Linq;
- using System.Web;
- using System.Web.Services;
- using System.Data;//
- using System.Data.SqlClient;//
- namespace DrillDownHighchart.Services
- {
- /// <summary>
- /// Summary description for WebServiceChart
- /// </summary>
- [WebService(Namespace = "http://tempuri.org/")]
- [WebServiceBinding(ConformsTo = WsiProfiles.BasicProfile1_1)]
- [System.ComponentModel.ToolboxItem(false)]
- // To allow this Web Service to be called from script, using ASP.NET AJAX, uncomment the following line.
- [System.Web.Script.Services.ScriptService]
- public class WebServiceChart : System.Web.Services.WebService
- {
- public class RevenueEntity
- {
- public string year { get; set; }
- public int amount { get; set; }
- public Boolean drilldown { get; set; }
- }
- [WebMethod]
- public List<RevenueEntity> GetRevenueByYear()
- {
- List<RevenueEntity> YearRevenues = new List<RevenueEntity>();
- DataSet ds = new DataSet();
- using (SqlConnection con = new SqlConnection("Data Source=.;Trusted_Connection=true;DataBase=test"))
- {
- using (SqlCommand cmd = new SqlCommand())
- {
- cmd.CommandText = "select year,SUM(amount)amount from tblRevenue group by year";
- cmd.Connection = con;
- using (SqlDataAdapter da = new SqlDataAdapter(cmd))
- {
- da.Fill(ds, "dsRevenue");
- }
- }
- }
- if (ds != null)
- {
- if (ds.Tables.Count > 0)
- {
- if (ds.Tables["dsRevenue"].Rows.Count > 0)
- {
- foreach (DataRow dr in ds.Tables["dsRevenue"].Rows)
- {
- YearRevenues.Add(new RevenueEntity
- {
- year = dr["year"].ToString(),
- amount = Convert.ToInt32(dr["amount"]),
- drilldown = true
- });
- }
- }
- }
- }
- return YearRevenues;
- }
- [WebMethod]
- public List<RevenueEntity> GetRevenueByQuarter(string year)
- {
- List<RevenueEntity> QuarterRevenues = new List<RevenueEntity>();
- DataSet ds = new DataSet();
- using (SqlConnection con = new SqlConnection("Data Source=.;Trusted_Connection=true;DataBase=test"))
- {
- using (SqlCommand cmd = new SqlCommand())
- {
- cmd.CommandText = "select quarter,SUM(amount)amount from tblRevenue where year='" + year + "' group by quarter";
- cmd.Connection = con;
- using (SqlDataAdapter da = new SqlDataAdapter(cmd))
- {
- da.Fill(ds, "dsQuarter");
- }
- }
- }
- if (ds != null)
- {
- if (ds.Tables.Count > 0)
- {
- if (ds.Tables["dsQuarter"].Rows.Count > 0)
- {
- foreach (DataRow dr in ds.Tables["dsQuarter"].Rows)
- {
- QuarterRevenues.Add(new RevenueEntity
- {
- year = dr["quarter"].ToString(),
- amount = Convert.ToInt32(dr["amount"])
- });
- }
- }
- }
- }
- return QuarterRevenues;
- }
- }
- }



Thirupathi SPosted Apr 20, 2018, 7:20 AM
Please help me to generate the 3'rd level chart... i tried but can't please help me...its emergency need....
Ram kumarPosted Mar 15, 2018, 11:32 PM
Valuable share . Can you please share 3 or 4 level drill down
Parameswaran RPosted Aug 14, 2017, 9:29 AM
How to convert this code to MVC without web service???
sonu jnncePosted Mar 11, 2017, 6:23 AM
How to call drilldown upto 4th level please help me.
Diwesh TanwarPosted Apr 13, 2016, 9:57 AM
valuable share . Can you please share 3 or 4 level drill down
Niranjan PoddarPosted Dec 19, 2015, 3:03 AM
Nice Article..Thanks for sharing
Santhakumar MunuswamyPosted Aug 22, 2015, 7:46 AM
Good Article. Thanks for sharing
Yashwanth MuthineniPosted Aug 22, 2015, 7:25 AM
Nice share
Shridhar SharmaPosted Aug 20, 2015, 11:09 AM
Good one Amol.
RakeshPosted Aug 20, 2015, 10:28 AM
Good start
Rajeesh MenothPosted Aug 20, 2015, 7:44 AM
Good One
Upendra Pratap ShahiPosted Aug 20, 2015, 7:31 AM
nice info sir...
Vaikesh K PPosted Aug 20, 2015, 7:06 AM
Good One
Gopi ChandPosted Aug 20, 2015, 6:25 AM
Awesome dude..
Sibeesh VenuPosted Aug 20, 2015, 6:24 AM
Nice Share
Gowtham KPosted Aug 20, 2015, 5:40 AM
Nice
Karthikeyan KPosted Aug 20, 2015, 5:19 AM
Good one sir...Thanks for share