I Use the following code for load the sql table values into the datatable
DataTable dt = new DataTable();
SqlConnection con = new SqlConnection("Connection String Here");
con.Open();
SqlCommand cmd = new SqlCommand("select * from ExportExcel", con);
dt.Load(cmd.ExecuteReader());
int total = 0;
foreach (DataRow row in dt.Rows)
{
int salaryvalue = Convert.ToInt32(row["Salary"]);
total = salaryvalue + total;
}
dt.Rows.Add("Salary");
dt.Rows.Add(total);
And I add Salary,total dynamically.But It Shows in first column one by one.
But I need salary in Department column,and total in Salary Column.How to do this?