Click here to Skip to main content
15,881,725 members

Enter the three nos, need average of only two greater nos.

Shiva from Bangalore, Karnataka asked:

Open original thread
Hi, i need avg of two greater nos, so kindly help me.

C#
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Drawing;
using System.Data;

public partial class HomePage : System.Web.UI.Page
{
    adminDB admDB;
    protected void Page_Load(object sender, EventArgs e)
    {
        txtRegNo.Focus();
    }
    protected void btnSubmit_Click(object sender, EventArgs e)
    {
       

        //Retrive Marks
        try
        {
            DataSet ds = new DataSet();
            admDB = new adminDB();
            ds = admDB.RetriveIAMArks1(txtRegNo.Text, txtIA1.Text, ddlBranch.Text);
            if (ds.Tables[0].Rows.Count > 0)
            {
                lblmsg.Visible = false;
                gvNames.Visible = true;
                gvNames.DataSource = ds;
                gvNames.DataBind();
                lbl1.Text= ds.Tables[0].Rows[0][7].ToString();
            }
            else
            {
                gvNames.Visible = true;
                lblmsg.Text = "No results found!";
            }

            admDB = new adminDB();
            ds = admDB.RetriveIAMArks2(txtRegNo.Text, txtIA2.Text, ddlBranch.Text);
            if (ds.Tables[0].Rows.Count > 0)
            {
                lblmsg.Visible = false;
                gvNames.Visible = true;
                gvNames.DataSource = ds;
                gvNames.DataBind();
                lbl2.Text = ds.Tables[0].Rows[0][7].ToString();
            }
            else
            {
                gvNames.Visible = true;
                lblmsg.Text = "No results found!";
            }

            admDB = new adminDB();
            ds = admDB.RetriveIAMArks3(txtRegNo.Text, txtIA3.Text, ddlBranch.Text);
            if (ds.Tables[0].Rows.Count > 0)
            {
                lblmsg.Visible = false;
                gvNames.Visible = true;
                gvNames.DataSource = ds;
                gvNames.DataBind();
                lbl3.Text = ds.Tables[0].Rows[0][7].ToString();
            }
            else
            {
                gvNames.Visible = true;
                lblmsg.Text = "No results found!";
            }
        }
        catch (Exception ex)
        {
            lblmsg.Text = ex.ToString();
        }

        try
        {
            DataSet ds = new DataSet();
            admDB = new adminDB();
            ds = admDB.ViewAssignmentbyRegNo(txtRegNo.Text, ddlBranch.Text);
            if (ds.Tables[0].Rows.Count > 0)
            {
                lblmsg.Visible = false;
                gvNames.Visible = true;
                Label7.Visible = true;
                gvNames.DataSource = ds;
                gvNames.DataBind();

                int ia1, ia2, 1a3;
                decimal avg;
                ia1 = Convert.ToInt16(lbl1.Text);
                ia2 = Convert.ToInt16(lbl2.Text);
                
                avg = (ia1 + ia2 + ia3 ) / 2;
                lblavg.Text = avg.ToString();
            }
            else
            {
                lblmsg.Visible = true;
                gvNames.Visible = false;
                lblmsg.Text = "No results found!";
            }
        }
        catch (Exception ex)
        {
            lblmsg.Text = ex.ToString();
        }

    }
    protected void LinkButton1_Click(object sender, EventArgs e)
    {
        Response.Redirect("HomePage.aspx");
    }
}
Tags: C#

Plain Text
ASM
ASP
ASP.NET
BASIC
BAT
C#
C++
COBOL
CoffeeScript
CSS
Dart
dbase
F#
FORTRAN
HTML
Java
Javascript
Kotlin
Lua
MIDL
MSIL
ObjectiveC
Pascal
PERL
PHP
PowerShell
Python
Razor
Ruby
Scala
Shell
SLN
SQL
Swift
T4
Terminal
TypeScript
VB
VBScript
XML
YAML

Preview



When answering a question please:
  1. Read the question carefully.
  2. Understand that English isn't everyone's first language so be lenient of bad spelling and grammar.
  3. If a question is poorly phrased then either ask for clarification, ignore it, or edit the question and fix the problem. Insults are not welcome.
  4. Don't tell someone to read the manual. Chances are they have and don't get it. Provide an answer or move on to the next question.
Let's work to help developers, not make them feel stupid.
Please note that all posts will be submitted under the http://www.codeproject.com/info/cpol10.aspx.



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900