PieChart Bind Tooltip With Data from a Stored Procedure

Posted: October 11, 2011 in ASP.Net Microsoft Chart

You can bind Tooltips for a PieChart with data from a stored procedure as follows:
ASPX

try
{
  Microsoft.Practices.EnterpriseLibrary.Data.Sql.SqlDatabase DAL = new Microsoft.Practices.EnterpriseLibrary.Data.Sql.SqlDatabase(MyConnectionString);
  System.Data.Common.DbCommand dbgCommand = DAL.GetStoredProcCommand("MyStoredProcedure");
  IDataReader rdr = DAL.ExecuteReader(dbgCommand);

  try
  {
    DataTable dt = new DataTable();
    dt.Load(rdr);

    if (dt.Rows.Count != 0)
    {
      MyChart.DataSource = dt;
      MyChart.DataBind();
      ...
      MyChart.Series["Default"].ToolTip = "#AXISLABEL";
    }
    else
    {
      ...
    }
  }
  finally
  {
    rdr.Close();
    rdr.Dispose();
  }
}
catch (Exception ex)
{
  ...
}
Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s