I was wondering if you can convert a label to a decimal. I know this can be done with a textbox, but i’m trying to see if it will work with a label. Here is the code, I’m getting error input message.
Label sitL = ((Label)FormView2.FindControl("SitUpsLabel"));
Label pushL = ((Label)FormView2.FindControl("pushUpsLabel"));
int count = 0;
int counter2 = 0;
decimal val = Decimal.Parse(sitL.Text);
decimal val2 = Decimal.Parse(pushL.Text);
No problem about doing that, but you won’t get values set on client side as you do for textboxes. Labels are not posted to server and it seems to me that you’re trying to process user input.
With that said, check that the content of the label can be converted to decimal. You could use
Decimal.TryParsemethod that will return false instead of throwing an exception in case the string can’t be converted.