Hi akhter,
It is not possible directly pass extra parameter using Chart Click event.
So on Click event you will get the Name and value.
Based on your Name you have to filter the DataTable and pass the extra parameter to the other page.
Check this example. Now please take its reference and correct your code.
HTML
<asp:Chart ID="EmployeeChartInfo" runat="server" OnClick="EmployeeChartInfo_Click">
<Titles>
<asp:Title ShadowOffset="3" Name="Items" />
</Titles>
<Legends>
<asp:Legend Alignment="Center" Docking="Bottom" IsTextAutoFit="False" Name="Default"
LegendStyle="Row" />
</Legends>
<Series>
<asp:Series Name="Default" />
</Series>
<ChartAreas>
<asp:ChartArea Name="ChartArea1" BorderWidth="1" />
</ChartAreas>
</asp:Chart>
Code
protected void Page_Load(object sender, EventArgs e)
{
if (!IsPostBack)
{
GetEmployeeChartInfo();
}
}
private void GetEmployeeChartInfo()
{
DataTable dt = GetData();
string[] x = new string[dt.Rows.Count];
int[] y = new int[dt.Rows.Count];
for (int i = 0; i < dt.Rows.Count; i++)
{
x[i] = dt.Rows[i][0].ToString();
y[i] = Convert.ToInt32(dt.Rows[i][1]);
}
EmployeeChartInfo.Series[0].Points.DataBindXY(x, y);
EmployeeChartInfo.Series[0].ChartType = SeriesChartType.Pie;
EmployeeChartInfo.ChartAreas["ChartArea1"].Area3DStyle.Enable3D = true;
EmployeeChartInfo.Legends[0].Enabled = true;
EmployeeChartInfo.Series[0].ToolTip = "Total : #VALY";
EmployeeChartInfo.Series[0].PostBackValue = "#VALY-#VALX";
}
private DataTable GetData()
{
DataTable dt = new DataTable();
using (SqlConnection con = new SqlConnection(ConfigurationManager.ConnectionStrings["constr"].ConnectionString))
{
con.Open();
SqlCommand cmd = new SqlCommand("SELECT shipcity as Sections, count(orderid), count(orderid) AS Total FROM orders where shipcountry = 'UK' group by shipcity", con);
SqlDataAdapter da = new SqlDataAdapter(cmd);
da.Fill(dt);
con.Close();
}
return dt;
}
protected void EmployeeChartInfo_Click(object sender, ImageMapEventArgs e)
{
DataTable dt = GetData().Select("Sections='" + e.PostBackValue.Split('-')[1] + "'").CopyToDataTable();
Response.Redirect("DefaultCS.aspx?Name=" + e.PostBackValue.Split('-')[1] + "&Value=" + e.PostBackValue.Split('-')[0] + "&Secid=" + dt.Rows[0][2]);
}