hi all,i'm still new to asp.net and i'm having some difficulties.

i have an asp page where it will display the result of a select count(*) result if the user clicks on a button control. i have bind the sqldatasource to the gridview.

the problem is i need to get a percentage value out of the select count(*) statement. the current output is it displays the total number and not in percentage value.

so how do i go about doing this. i got suggestions from others saying that i need to assign a variable to the result of select count(*) in order to get the percentage.

much thanks people. :)

protected void button4submit_Click(object sender, EventArgs e)
    {
        SqlDataSource ds = SqlDataSource1;

        string SQLString1 = "SELECT DISTINCT COUNT(*) FROM [INGATE] WHERE VEHNO=' ' AND LICENSENO <> ' '";


        ds.SelectCommand = SQLString1;


        GridView1.DataSource = ds;
        GridView1.DataBind();
        GridView1.Visible = true;

    }

Recommended Answers

All 3 Replies

Hi

Are you using SQL server? If so, then why don't you create a stored procedure to calculate the percentage for you and rather that executing a long SQL string, you could just execute the stored procedure (getting the SQL server to do the work for you) and print the return value (the percentage). If you need help doing this, i have some simple code to help you

Hope this helps

Kev

Hi

Are you using SQL server? If so, then why don't you create a stored procedure to calculate the percentage for you and rather that executing a long SQL string, you could just execute the stored procedure (getting the SQL server to do the work for you) and print the return value (the percentage). If you need help doing this, i have some simple code to help you

Hope this helps

Kev

santhosh

Hi would it possible for you to send me the code you have for this. i a novice in .net and learning as I go along. I have some expereince of using stored procedures, but your help will be greatly received

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.