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.
Answer a question in the forums and earn +20 SHARP for every answer.
See unanswered questions
DevSocialUpcoming · 3rd editionAI Agents ConferenceDec 1–3, 2026Live onlineFree to attend4days leftRegister
Satyapriya NayakRank #47 · 31.5K reputationPosted Jan 7, 2012, 1:07 AM EST
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
Jignesh TrivediRank #16 · 50.3K reputationPosted Jan 8, 2012, 6:36 PM EST
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.
Satyapriya NayakRank #47 · 31.5K reputationPosted Jan 8, 2012, 7:37 PM EST
Chiranjeevi Aripaka105 reputationPosted Jan 8, 2012, 7:37 PM EST
thank you so much.......
Chiranjeevi Aripaka105 reputationPosted Jan 8, 2012, 7:38 PM EST
thank you so much.......