Пример #1
0
 protected void gvServer_RowUpdating(object sender, GridViewUpdateEventArgs e)
 {
     try
     {
         Label   lblServerID   = (Label)gvServer.Rows[e.RowIndex].FindControl("lblServerID");
         int     ServerID      = Convert.ToInt16(lblServerID.Text.ToString());
         TextBox txtServerName = (TextBox)gvServer.Rows[e.RowIndex].FindControl("txtServerName");
         string  strServerName = txtServerName.Text.ToString();
         if (strServerName != "")
         {
             bool flag = CheckIFServerExists(strServerName);
             if (flag == false)
             {
                 objclsBALApplication = new clsBALApplication();
                 objclsBALApplication.UpdateServer(ServerID, strServerName);
                 gvServer.EditIndex = -1;
                 PopulateGrid();
                 if (ViewState["SortExpression"] != null && ViewState["sortDirection"] != null)
                 {
                     SortGridView(ViewState["SortExpression"].ToString(), ViewState["sortDirection"].ToString());
                 }
                 lblSuccess.Text = "Server update successfully.";
             }
             else
             {
                 if (Session["serverName"].ToString() == strServerName)
                 {
                     lblError.Text = "There is no change in server name.";
                     // gvServer.EditIndex = -1;
                 }
                 else
                 {
                     lblError.Text = "Server already exists.";
                     // gvServer.EditIndex = -1;
                 }
             }
         }
         else
         {
             lblError.Text = "Please fill server name.";
         }
     }
     catch (NullReferenceException)
     {
         Response.Redirect("wfrmErrorPage.aspx", true);
     }
     catch (Exception ex)
     {
         HttpContext  context            = HttpContext.Current;
         LogException objclsLogException = new LogException();
         objclsLogException.LogErrorInDataBase(ex, context);
         Response.Redirect("wfrmErrorPage.aspx", true);
     }
 }