We use cookies to give you the best experience on our website. If you continue to browse, then you agree to our privacy policy and cookie policy.
Unfortunately, activation email could not send to your email. Please try again.

How to bind SQL query data to Chartwebcontrol?

Thread ID:

Created:

Updated:

Platform:

Replies:

110326 Jul 30,2013 02:49 AM Aug 16,2013 04:55 AM ASP.NET Web Forms (Classic) 4
loading
Tags: Chart
Sam
Asked On July 30, 2013 02:49 AM

Hi All,
How to bind SQL query data to Chartwebcontrol?

Sam
Replied On July 31, 2013 06:42 AM

After bind the data to Chartwebcontrol, want to add onRegionClick function should land to a gruopinggrid.

Anandaraj T [Syncfusion]
Replied On August 1, 2013 06:33 AM

Hi Sam,

Thanks for the update.

We suggest you to use "ChartRegionClick" event of chart web control to add an event for chart region.

Please refer the following code snippet to achieve this:
<code>
            //Adding region click event for chart web control
            this.ChartWebControl1.ChartRegionClick += new            Syncfusion.Web.UI.WebControls.Chart.ChartWebRegionMouseHandler(ChartWebControl1_ChartRegionClick);


 void ChartWebControl1_ChartRegionClick(object sender, Syncfusion.Web.UI.WebControls.Chart.ChartWebRegionMouseArgs e)
        {
            //Code for grouping grid
        }

For more information about chart events, please refer our online documentation in the following link:
Chart Control Events

Please let us know if you have any concern.

Regards,
Anandaraj


Sam
Replied On August 14, 2013 09:57 AM

ChartRegionClick not working(triggered) in my following code:

using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Data;
using System.Data.SqlClient;
using System.Data.SqlServerCe;
using Syncfusion.Windows.Forms.Chart;

namespace SQL_ServerConn
{

    public partial class _Default : System.Web.UI.Page
    {
         
        
        SqlConnection myConnection = null;
        SqlDataAdapter SqlDA1;
        ChartDataBindModel model1 = null;
        DataTable data;
        DataSet ds1;
        string ConnectionString = "Server=!!!; Database=$$$; User Id=**; password=$$$";
        protected void Page_Load(object sender, EventArgs e)
        {
            //Bind data to GridGroupingControl.
            try
            {
                GetData();
               
            }
            catch (SqlException ex)
            {

            }
            finally
            {

            }

        }
        private void GetData()
        {
            //To allow ASP.NET to use SQL Compact Server 3.5
            //AppDomain.CurrentDomain.SetData("SQLServerCompactEditionUnderWebHosting", true);

            try
            {
                myConnection = new SqlConnection(ConnectionString);
                string query1 = "";
                query1 = "select ROW_NUMBER() over(order by AC.AnalysisCode) as Id, isnull(AC.AnalysisCode,'Not Link')  AnalysisCode,isnull(AC.Description,'Not Link') as Name ,count(*) As Total from podetail  pd inner join POHeader ph on pd.Company =ph.Company and pd.ponum  = ph.PONum inner join  Part P on pd.Company=P.Company and pd.PartNum=P.PartNum inner join AnalysisCd AC on P.Company=AC.Company   and P.Mtl_AnalysisCode=AC.AnalysisCode where   pd.company='COMP01' group by  AC.Description,AC.AnalysisCode having count(*)> 5";
                SqlCommand SqlCmd1 = new SqlCommand(query1, myConnection);

                myConnection.Open();
                SqlDA1 = new SqlDataAdapter(SqlCmd1.CommandText, myConnection);
                ds1 = new DataSet();

                DataTable dt = new DataTable("ChartSeries");
                SqlDA1.Fill(dt);
                data = dt;
                this.model1 = new ChartDataBindModel(dt);
                this.model1.XName = "ID";
                this.model1.YNames = new string[] { "Total" };

                ChartSeries series1 = new ChartSeries("Series1");
                series1.Text = series1.Name;
                series1.Type = ChartSeriesType.Pie;
                series1.SeriesModel = this.model1;

                this.ChartWebControl1.Series.Add(series1);
                this.ChartWebControl1.ChartRegionClick += new Syncfusion.Web.UI.WebControls.Chart.ChartWebRegionMouseHandler(ChartWebControl1_ChartRegionClick);
             // this.ChartWebControl1.ChartRegionClick += new Syncfusion.Web.UI.WebControls.Chart.ChartWebRegionMouseHandler(ChartWebControl1_ChartRegionClick);



            }
            catch (SqlException ex)
            {
                throw ex;
            }
            catch (Exception ex)
            {
                throw ex;
            }

        }
          void ChartWebControl1_ChartRegionClick(object sender, Syncfusion.Web.UI.WebControls.Chart.ChartWebRegionMouseArgs e)
      //  void ChartWebControl1_ChartRegionClick(System.Object sender, Syncfusion.Web.UI.WebControls.Chart.ChartWebRegionMouseArgs e)
        {
                int Poi = Convert.ToInt32(e.PointIndex);
                string Fstr = null;
                string Fstr1 = null;
                Fstr = "id=" + e.PointIndex + 1;

                DataRow[] drow;
                if (data.Select(Fstr).Length > 0)
                {
                    drow = data.Select(Fstr, "AnalysisCode ASC");
                    Fstr1 = drow[0].ItemArray[1].ToString();
                }

                Console.Write(Fstr1.ToString());

                try
                {
                    SqlConnection con = new SqlConnection(@"Server=!!!; Database=###; User Id=@@; password=$$");
                    DataSet dSet = new DataSet();
                    SqlDataAdapter da = new SqlDataAdapter("select p.company,p.ponum as orderNum, p.orderdate,v.name as supplier,p.shipcountry as country,   Pr.Duedate as DeliveryDate,  p.fob as Mode,p.termscode as terms,P.ShipName,   (p.shipaddress1+ ',' + P.ShipAddress2 + ',' + ShipCity + ',' +ShipZIP  ) as Deliverat,   p.entryperson as Createdby,(p.shipaddress1 + ',' + P.ShipAddress2 + ',' + ShipCity + ',' + ShipZIP  ) as Address,  p.character01 as comments,p.approvalstatus,pr.ContainerID,Pr.TranType,P.CurrencyCode,P.ExchangeRate,pl.ponum,pl.poline as sno,pl.Partnum,  pl.linedesc as Description, pl.ium as UOM,pl.orderqty as Qty,pl.xorderqty,Pl.unitcost as Rate,pl.docunitcost,pl.unitcost ,   (pl.orderqty * pl.unitcost) As Value1,(pl.orderqty * pl.docunitcost)As Value2,(Select currDesc from Currency where Company=P.company and BaseCurr=1 )  As curr1,   (Select currDesc from Currency where Company=P.company and CurrencyCode=P.CurrencyCode )  As curr2   from podetail pl ,Porel Pr,poheader p, vendor v, Part Prt, AnalysisCd A   where p.company = pl.company And p.company = pr.company And P.company = v.company   and P.Ponum=pl.ponum and P.ponum=pr.ponum and Pl.poline=pr.poline and p.vendornum=v.vendornum   and pl.company=Prt.company and A.Company = Pl.Company and Prt.PartNum=pl.Partnum and A.AnalysisCode = Prt.Mtl_AnalysisCode      and A.AnalysisCode ='" + Fstr1 + "' and P.company in ( 'COMP01')", con);
                    DataTable td;
                    da.Fill(dSet);
                    td = dSet.Tables[0];

                     GridGroupingControl1.DataSource = td;

                     GridGroupingControl1.DataBind();
                    con.Close();
                }
                catch (SqlException ex)
                {

                }
                finally
                {

                }

             

        }
    }
}


Anandaraj T [Syncfusion]
Replied On August 16, 2013 04:55 AM

Hi Sam,

Thanks for the update.

Since same query is asked in incident 111214, we suggest you to follow up incident 111214 for solution.

Please let us know if you have any concern.

Regards,
Anandaraj

CONFIRMATION

This post will be permanently deleted. Are you sure you want to continue?

Sorry, An error occured while processing your request. Please try again later.

You are using an outdated version of Internet Explorer that may not display all features of this and other websites. Upgrade to Internet Explorer 8 or newer for a better experience.

;