I want to Update An Number of goals That a Player Scored so if he socred a goal I want to do an update for his number of goals... I got an Error in my Code And I don\'t know how
If you're looking to default to 0 on an empty textbox:
int i = string.IsNullOrEmpty((SoccerTable.FooterRow.FindControl("txtAchNumsFooter") as TextBox).Text.Trim()) ? 0 : int.Parse((SoccerTable.FooterRow.FindControl("txtAchNumsFooter") as TextBox).Text.Trim());
If you're looking to default to 0 with any bad formatted input:
int i;
if (!int.TryParse((SoccerTable.FooterRow.FindControl("txtAchNumsFooter") as TextBox).Text.Trim(), out i)) i = 0;
@Alex It seems to be like a format exception at the line int a = int.Parse((SoccerTable.FooterRow.FindControl("txtAchNumsFooter") as TextBox).Text.Trim());.
In your case, the possibility is that the value return by the textbox is not a valid integer value. Thats why you are getting this error.
Can you try debugging your code and do quickwatch on this statement 'SoccerTable.FooterRow.FindControl("txtAchNumsFooter") as TextBox).Text.Trim()'. Check what you get.