please help me in aggreating a set of marks . in c# using asp
| | enter marks |
| TEXTBOX1 | 54 |
| TEXTBOX2 | 65 |
| TEXTBOX3 | 86 |
| TEXTBOX4 | 56 |
| TEXTBOX5 | 25 |
| TEXTBOX6 | 65 |
| TEXTBOX7 | 86 |
| total | 437 |
| aggreate | 54.625 |
| | enter marks |
| TEXTBOX1 | 54 |
| TEXTBOX2 | 65 |
| TEXTBOX3 | 86 |
| TEXTBOX4 | 56 |
| TEXTBOX5 | 25 |
| TEXTBOX6 | 65 |
| TEXTBOX7 | 86 |
| total | 437 |
| aggreate | 54.625 |
Know the answer? Post it — somebody with the same question will find it here.
Sign in to answer this question
It is the same account you read, post and publish with — and you will come straight back to this page.
Satyapriya NayakPosted Jan 7, 2012, 6:07 AM
Try this...
protected void Button1_Click(object sender, EventArgs e)
{
decimal a1 = System.Convert.ToDecimal(TextBox1.Text);
decimal a2 = System.Convert.ToDecimal(TextBox2.Text);
decimal a3 = System.Convert.ToDecimal(TextBox3.Text);
decimal a4 = System.Convert.ToDecimal(TextBox4.Text);
decimal a5 = System.Convert.ToDecimal(TextBox5.Text);
decimal a6 = System.Convert.ToDecimal(TextBox6.Text);
decimal a7 = System.Convert.ToDecimal(TextBox7.Text);
decimal total = a1 + a2 + a3 + a4 + a5 + a6 + a7;
TextBox8.Text = total.ToString();
decimal agg = (total / 7);
TextBox9.Text=agg.ToString();
}
Thanks
Chiranjeevi AripakaPosted Jan 9, 2012, 12:38 AM
thank you so much.......
Chiranjeevi AripakaPosted Jan 9, 2012, 12:37 AM
thank you so much.......
Satyapriya NayakPosted Jan 9, 2012, 12:37 AM
Jignesh TrivediPosted Jan 8, 2012, 11:36 PM
Try following code.
in ASPX
....
....
....
....
In CS
protected void Button1_Click(object sender, EventArgs e)
{
double total=0;int count=0;
foreach (var control in mytestdiv.Controls)
{
TextBox txtcontrol;
txtcontrol = control as TextBox;
if(txtcontrol !=null)
{
total += double.Parse(txtcontrol.Text);
count++;
}
}
double aggreate = total / count;
}
hope this help.