I want to update and sum a num paramter to my database… Got Problem… Gridview

前端 未结 2 1691
名媛妹妹
名媛妹妹 2021-01-29 12:14

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

相关标签:
2条回答
  • 2021-01-29 12:49

    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;
    
    0 讨论(0)
  • 2021-01-29 13:02

    @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.

    0 讨论(0)
提交回复
热议问题