Click here to Skip to main content
15,911,531 members
Please Sign up or sign in to vote.
1.00/5 (2 votes)
See more:
Grid view Minits minus permissionhrs=180 mints below Minis data

Late Mints Details
ProcessDate	LateIn	Mints
04 Mar 2014	20	15
05 Mar 2014	22	30
11 Mar 2014	18	15
20 Mar 2014	14	15
21 Mar 2014	30	30
22 Mar 2014	25	30
27 Mar 2014	26	30
28 Mar 2014	28	30


Permissionhrs minus minits Example
180-15 result is 165
165-30 result is 135
135-15 result is 120
120-15 result is 105
105-30 result is 75
75-30  result is 45
45-30  result is 15
15-30  result is -15

how to count howmany time -15 or anyone minusvalue came.

My Source Is code using but not came pls how to count minus(-)values came this grid
permissionhrs value is 180

C#
 int halfday = 0;
int permissionResult = permissionhrs;
foreach (GridViewRow gvRows in gvLatemints.Rows)
{

    total2 = permissionResult - Convert.ToInt32(gvRows.Cells[2].Text.Trim());
    lblError.Text = "Total Leave :" + total2;
    permissionResult = permissionResult - Convert.ToInt32(gvRows.Cells[2].Text.Trim());
    if (permissionResult.ToString() == "-15")or anyone minus(-)value
    {
        halfday++;
        lblError.Text = "Total Leave :" + halfday;

    }


Thanks
Posted
Updated 27-Oct-14 4:48am
v4
Comments
ZurdoDev 27-Oct-14 10:31am    
I don't understand.

Are you saying you want "any minus value" meaning anything less than 0? That should be easy, just use < 0 instead of == "-15"
Maciej Los 27-Oct-14 12:25pm    
Please, provide more details.

Chang this line as

if (convert.toint32(permissionResult.ToString())> = 0)
 
Share this answer
 
If all you want is to detect when permissionResult is negative then use:
C#
if (permissionResult < 0)

The .ToString() is totally unnecessary and inefficient!
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



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