我有一个图表控件,我已经在datalist itemtemplate中进行了,因为我想在单击时显示所有学生成绩单的图表。 我遇到了一个问题,因为当我将价值绑定到图表时,它总是显示所有其他图表上的最后一个学生标记,我希望不同的学生标记显示在不同的图表上。请帮助我
protected void dlCategory_ItemDataBound(object sender, DataListItemEventArgs e)
{
DataSet dsStu = new DataSet();
string sqlStu = "SELECT distinct t.studentcode FROM tblcce9_studentgrades t join tblstudent st on t.studentcode=st.studentcode where examname='" + lblExamCode.Text + "' and st.classcode='" + lblClassCode.Text + "' and t.subpart='1' and st.recordstatus <>'D'";
dsStu = obj.openDataset(sqlStu, Session["SCHOOLCODE"].ToString());
if (dsStu.Tables[0].Rows.Count > 0)
{
for (int i = 0; i < dsStu.Tables[0].Rows.Count; i++)
{
if (e.Item.ItemType == ListItemType.AlternatingItem || e.Item.ItemType == ListItemType.Item)
{
string sqlchart = "select cl.classname,Concat(ga.forename,' ',ga.Surname) as fathername,s.studentcode,s.admissionnumber,s.studentname, sum(g.grade)" +
" as totalmarks,a.assessareaname,sub.subassessname,sub.maxmarks , e.examname from tblcce9_studentgrades g inner join" +
" tblstudent s on s.studentcode = g.studentcode inner join tblcce9_assessmentareas a on g.assessmentareacode =a.assessareacode" +
" inner join tblcce9_subassess sub on g.subassesscode=sub.id inner join tblcce9_examname e on g.examname=e.id inner" +
" join tblguardian ga on s.studentcode=ga.studentcode inner join tblclass cl on s.classcode = cl.classcode where" +
" sub.classcode='" + lblClassCode.Text + "' and s.studentcode='" + dsStu.Tables[0].Rows[i]["studentcode"] + "' and ga.relationshipcode='14' and s.recordstatus<>'D' group by assessareaname order by a.priority";
DataSet dschart = new DataSet();
dschart = obj.openDataset(sqlchart, Session["SCHOOLCODE"].ToString());
if (e.Item.ItemType == ListItemType.AlternatingItem || e.Item.ItemType == ListItemType.Item)
{
Chart chrt = (Chart)e.Item.FindControl("Chart1");
if (dschart.Tables[0].Rows.Count > 0)
{
string[] x = new string[dschart.Tables[0].Rows.Count];
int[] y = new int[dschart.Tables[0].Rows.Count];
for (int k = 0; k < dschart.Tables[0].Rows.Count; k++)
{
x[k] = dschart.Tables[0].Rows[k]["assessareaname"].ToString();
y[k] = Convert.ToInt32(dschart.Tables[0].Rows[k]["totalmarks"].ToString());
}
chrt.Series[0].Points.DataBindXY(x, y);
chrt.Series[0].ChartType = SeriesChartType.Column;
//chrt.ChartAreas["ChartArea1"].Area3DStyle.Enable3D = true;
//chrt.Legends[0].Enabled = true;
}
}
}
}
}
}