protected void Page_Load(object sender, EventArgs e) { if (!this.IsPostBack) { double lowerrange = 0.1; double upperrange = 3.0; double lobound=0.1; double upbound=0.5; DataTable dt = new DataTable(); dt.Columns.Add("Random Numbers", typeof(double)); dt.Columns.Add("loss", typeof(double)); Random random = new Random(Guid.NewGuid().GetHashCode()); for (int i = 0; i < 1000; i++) { DataRow dr = dt.NewRow(); dr["Random Numbers"] = random.NextDouble() * (upperrange-lowerrange) + lowerrange; dr["loss"] = random.NextDouble() * (upbound - lobound) + lobound; dt.Rows.Add(dr); } GridView1.DataSource = dt; GridView1.DataBind(); }
//for sum of all values of one column, use following code var sumOfLoss = dt.Select().Sum(dr => Convert.ToDecimal(dr["loss"])); var sumOfRandom = dt.Select().Sum(dr => Convert.ToDecimal(dr["Random Numbers"]));//(loss,Random Numbers) your column name
var
This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)