Click here to Skip to main content
15,889,595 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
I want to Print the total marks of student on datagrid footer

What I have tried:

C#
DataTable dt=new DataTable();
dt.Columns.Add("Subject",typeof(string));
dt.Columns.Add("Paper",typeof(string));
dt.Columns.Add("MaxMarks",typeof(string));
dt.Columns.Add("MinMarks",typeof(string));
dt.Columns.Add("ObtainMarks",typeof(string));
int totalMax = 0, totalMin = 0, totalObtain = 0;
DataGridShow.ItemsSource = ds.Tables[0].DefaultView ;
for (int i = 0; i < DataGridShow.Items.Count; i++)
{
    try
    {
        DataGridShow.SelectedIndex = i;
        DataRowView drv = (DataRowView)DataGridShow.SelectedItem;
        totalMax = totalMax + Convert.ToInt32(drv["MaxMarks"]);
        totalMin = totalMin + Convert.ToInt32(drv["MinMarks"]);

        totalObtain = totalObtain + Convert.ToInt32(drv["ObtainMarks"]);
    }
    catch(Exception x) { }
}

dt.Rows.Add("Total","",totalMax.ToString(),totalMin.ToString(),totalObtain.ToString());
DataGridShow.Items.Add(dt.Rows[0]);
Posted
Updated 17-Mar-16 21:29pm
v2

1 solution

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