Want to protect your cyber security and still get fast solutions? Ask a secure question today.Go Premium

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 173
  • Last Modified:

Total a column -- But if there is a alpha character skip that record

I have a web page that totals a field called Month Value. I have another field on the same page that displays YTD of the month value field. Users are allowed to enter NA or TBD in the month value field. I want to calculate the YTD values and skip the records that have a value of NA or YTD.
0
DCampbell2006
Asked:
DCampbell2006
  • 2
2 Solutions
 
Bob LearnedCommented:
You could use double.TryParse to attempt to parse the field value:

double result = 0;
if (double.TryParse(dr["MonthValue"])
{
}

Bob
0
 
JimBrandleyCommented:
Bob is right on the approach, but missed the second argument. It needs to be:
double result = 0;
if (double.TryParse(dr["MonthValue"], result)
{
}

Jim
0
 
Bob LearnedCommented:
Jim helped me out, but forgot the out keyword:

double result = 0;
if (double.TryParse(dr["MonthValue"], out result)
{
}

Bob
0
 
Computer101Commented:
Forced accept.

Computer101
EE Admin
0

Featured Post

Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now