public partial class WebForm1 : System.Web.UI.Page { int sum3; protected void Page_Load(object sender, EventArgs e) { if (!IsPostBack) { DataTable dTable = new DataTable("mainTable"); DataColumn Name = new DataColumn("Name"); dTable.Columns.Add(Name); DataColumn Marks = new DataColumn("Marks"); dTable.Columns.Add(Marks); DataColumn Marks2 = new DataColumn("Marks2"); dTable.Columns.Add(Marks2); DataColumn Total = new DataColumn("Total"); dTable.Columns.Add(Total); int sum = 0; int sum2 = 0; DataRow dRow = null; for (int i = 0; i < 5; i++) { dRow = dTable.NewRow(); dRow["Name"] = i + " - Sagar"; dRow["Marks"] = i; sum += i; dRow["Marks2"] = i + 5; sum2 += i + 5; dRow["Total"] = i + i + 5; sum3 += i + i + 5; dTable.Rows.Add(dRow); } Page.ClientScript.RegisterStartupScript(this.GetType(), "alert", "showAlert(" + sum3.ToString() + ");", true); //dRow = dTable.NewRow(); //dRow["Name"] = "Total"; //dRow["Marks"] = sum; //dRow["Marks2"] = sum2; //dRow["Total"] = sum3; //dTable.Rows.Add(dRow); aspDataGrid.DataSource = dTable; aspDataGrid.DataBind(); } } protected void btn_Submit_Click(object sender, EventArgs e) { marks1.Text = "Total Marks : " + sum3.ToString(); Page.ClientScript.RegisterStartupScript(this.GetType(), "alert", "showAlert(" + sum3.ToString() + ");", true); } }
var
This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)