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

前端 未结 2 1695
名媛妹妹
名媛妹妹 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;
    

提交回复
热议问题