Ejemplo n.º 1
0
        protected void gvPlayer_RowUpdating(object sender, GridViewUpdateEventArgs e)
        {
            var tbShirt     = gvPlayer.Rows[gvPlayer.EditIndex].FindControl("tbShirt") as TextBox;
            var tbShorts    = gvPlayer.Rows[gvPlayer.EditIndex].FindControl("tbShorts") as TextBox;
            var tbSock      = gvPlayer.Rows[gvPlayer.EditIndex].FindControl("tbSock") as TextBox;
            var ddlIsActive = gvPlayer.Rows[gvPlayer.EditIndex].FindControl("ddlIsActive") as DropDownList;

            if (tbShirt != null && tbShorts != null && tbSock != null && ddlIsActive != null)
            {
                try
                {
                    var pid = (int)gvPlayer.DataKeys[gvPlayer.EditIndex].Value;

                    int _shirt;
                    int _shorts;
                    int _sock;

                    if (int.TryParse(tbShirt.Text.Trim(), out _shirt) &&
                        int.TryParse(tbShorts.Text.Trim(), out _shorts) &&
                        int.TryParse(tbSock.Text.Trim(), out _sock) &&
                        !string.IsNullOrEmpty(ddlIsActive.SelectedValue))
                    {
                        PlayerStrip.UpdatePlayerInfo(pid, _shirt, _shorts, _sock,
                                                     Convert.ToBoolean(ddlIsActive.SelectedValue));
                    }
                    else
                    {
                        throw new Exception("请正确填写会员信息");
                    }
                }
                catch (Exception ex)
                {
                    ClientScript.RegisterClientScriptBlock(typeof(string), "failed",
                                                           $"alert('{ex.Message}');", true);
                }
            }

            gvPlayer.EditIndex = -1;

            BindData();
        }