Click here to Skip to main content
15,912,294 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
See more:
sql = "select distinct r.rate as Rate,f.bfid as BFid FROM bthfac AS f,batch b,facfeedback r";
sql = sql + " where month(b.examdate)= '" + Ddlmonth.Text + "' and year(b.examdate)= '" + DropDownList2.Text + "' and ";
sql = sql + " r.bfid=f.bfid and b.bthid=f.bthid and f.facid = '" + DropDownList4.SelectedValue + "'";
dr = scon.ReadSql(sql);
GridView3.DataSource = dr;
GridView3.DataBind();
GridView3.Visible = true;


//Displaying the gridview records in the chart for that code as follows

dr = scon.ReadSql(sql);
int[] LRate = new int[GridView3.Rows.Count];
int[] LBFid = new int[GridView3.Rows.Count];
int i = 0;
while (dr.Read())
{
LRate[i] = int.Parse(dr[0].ToString());
LBFid[i] = int.Parse(dr[1].ToString());
Chart1.Series.Add(LBFid[i].ToString());
i = i + 1;
}


in the run mode when i execute shows error as follows;


:A chart element with the name '65' already exists in the 'SeriesCollection'.

what is the problem in my above code.

please help me.


Note it is web application using asp.net using c#.

Regards
Narasiman P.
Posted

1 solution

I think it's this part:

C#
Chart1.Series.Add(LBFid[i].ToString());


Is trying to add an element with the same name.
You should check if there is already an element with that Name before you add it to the Collection.
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900