D
David
Hi all,
I have this code...
if (!AuditFailed)
{
dr["Total number of passed
audits"] = Convert.ToInt32(dr["Total number of passed audits"]) + 1;
Totals++;
TotalPassed++;
}
else
{
dr["Total number of failed
audits"] = Convert.ToInt32(dr["Total number of failed audits"]) + 1;
Totals++;
}
// Calculate Percentage of
satisfactory v unsatisfactory.
if (Totals > 0)
{
//Response.Write("Total:" + Totals + " TotalPassed:" + TotalPassed + "<br
/>");
decimal Satisfactory = (100M
/ Totals) * TotalPassed;
decimal Unsatisfactory =
100M - Satisfactory;
//Response.Write("SAT:" + Satisfactory.ToString("N2") + " UNSAT:" +
Unsatisfactory.ToString("N2") + "<br />");
dr["Percentage of passed
audits"] = Satisfactory.ToString("N2") + " %";
dr["Percentage of failed
audits"] = Unsatisfactory.ToString("N2") + " %";
//Response.Write("drSAT: " + dr["Percentage of passed audits"].ToString() +
" drUNSAT: " + dr["Percentage of failed audits"].ToString() + "<br />");
}
As you can see, I have response.write out to screen to see what is
happening. Ultimately, the display is a gridview.
The Totals and TotalPassed are decimal values. When I response.write to the
screen, I get the correct values, but when I display in gridview, the
Percentage columns are showing 0% and 100%. However, it displays perfectly
on my XP machine.
What is quite weird... I set up the columns by adding them to my DataTable.
I give them intial values of 100% and 0%. I then do the calculation as above
and populate the values. However, if I get any unsatisfactory, the
percentage of failed audits becomes 100% (100.00%). (It should be 40%)
I am really puzzled about this. (Initially, I didn't have 100M, I just had
100, but this didn't work either, whilst it worked fine on my XP machine.)
Any pointers would be very much appreciated.
This is .NET 2.0
--
Best regards,
Dave Colliver.
http://www.AshfieldFOCUS.com
~~
http://www.FOCUSPortals.com - Local franchises available
I have this code...
if (!AuditFailed)
{
dr["Total number of passed
audits"] = Convert.ToInt32(dr["Total number of passed audits"]) + 1;
Totals++;
TotalPassed++;
}
else
{
dr["Total number of failed
audits"] = Convert.ToInt32(dr["Total number of failed audits"]) + 1;
Totals++;
}
// Calculate Percentage of
satisfactory v unsatisfactory.
if (Totals > 0)
{
//Response.Write("Total:" + Totals + " TotalPassed:" + TotalPassed + "<br
/>");
decimal Satisfactory = (100M
/ Totals) * TotalPassed;
decimal Unsatisfactory =
100M - Satisfactory;
//Response.Write("SAT:" + Satisfactory.ToString("N2") + " UNSAT:" +
Unsatisfactory.ToString("N2") + "<br />");
dr["Percentage of passed
audits"] = Satisfactory.ToString("N2") + " %";
dr["Percentage of failed
audits"] = Unsatisfactory.ToString("N2") + " %";
//Response.Write("drSAT: " + dr["Percentage of passed audits"].ToString() +
" drUNSAT: " + dr["Percentage of failed audits"].ToString() + "<br />");
}
As you can see, I have response.write out to screen to see what is
happening. Ultimately, the display is a gridview.
The Totals and TotalPassed are decimal values. When I response.write to the
screen, I get the correct values, but when I display in gridview, the
Percentage columns are showing 0% and 100%. However, it displays perfectly
on my XP machine.
What is quite weird... I set up the columns by adding them to my DataTable.
I give them intial values of 100% and 0%. I then do the calculation as above
and populate the values. However, if I get any unsatisfactory, the
percentage of failed audits becomes 100% (100.00%). (It should be 40%)
I am really puzzled about this. (Initially, I didn't have 100M, I just had
100, but this didn't work either, whilst it worked fine on my XP machine.)
Any pointers would be very much appreciated.
This is .NET 2.0
--
Best regards,
Dave Colliver.
http://www.AshfieldFOCUS.com
~~
http://www.FOCUSPortals.com - Local franchises available