Create Dynamic Ajax Pie Chart

Creating dynamic Ajax Pie Chart in with Database. To implement Ajax pie chart with database first add AjaxControlToolkit to bin folder.

Download the DLL using the below link

Download DLL

First create a table named country details in sql server with name and value field. Download the script for the Country details table below.

Download Script

Add below code in the aspx page of empty web application.

<%@ Register TagPrefix="ajaxToolkit" Assembly="AjaxControlToolkit" Namespace="AjaxControlToolkit" %>

<!DOCTYPE html>
<html xmlns="">
<head id="Head1" runat="server">
    <title>Pie Chart Example with Database in</title>
    <form id="form1" runat="server">
        <div style="width: 40%">
            <asp:ScriptManager ID="ScriptManager1" runat="server"></asp:ScriptManager>
            <ajaxToolkit:PieChart ID="countrychart" runat="server" ChartHeight="300"
                ChartWidth="450" ChartTitle="World wide Data usage %" ChartTitleColor="#0E426C">

 C# code

protected void Page_Load(object sender, EventArgs e)
           DataTable dt = new DataTable();
           using (SqlConnection con = new SqlConnection(SQLConnectionString))
               SqlCommand cmd = new SqlCommand("select name,total=value from countrydetails order by total desc", con);
               SqlDataAdapter da = new SqlDataAdapter(cmd);
           foreach (DataRow dr in dt.Rows)
               countrychart.PieChartValues.Add(new AjaxControlToolkit.PieChartValue
                   Category = dr["name"].ToString(),
                   Data = Convert.ToDecimal(dr["total"]),


Demo Code

Download Demo