コード例 #1
0
        protected void AdminFormView_ItemUpdating(object sender, FormViewUpdateEventArgs e)
        {
            DataKey      key           = AdminFormView.DataKey;
            Label        lblEmpID      = (Label)AdminFormView.FindControl("lblEmpID");
            TextBox      TxtEmpName    = (TextBox)AdminFormView.FindControl("TxtEmpName");
            DropDownList DdlRoleName   = (DropDownList)AdminFormView.FindControl("DdlRoleName");
            TextBox      TxtEmpAddress = (TextBox)AdminFormView.FindControl("TxtEmpAddress");

            TextBox TxtContact = (TextBox)AdminFormView.FindControl("TxtContact");
            TextBox TxtEmail   = (TextBox)AdminFormView.FindControl("TxtEmail");


            TextBox TxtDepartment  = (TextBox)AdminFormView.FindControl("TxtDepartment");
            TextBox TxtDesignation = (TextBox)AdminFormView.FindControl("TxtDesignation");

            SqlConnection conn = new SqlConnection(connStr);

            com.Connection  = conn;
            com.CommandText = "UPDATE EMPLOYEE_DETAILS SET Emp_Name ='" + TxtEmpName.Text + "',Role ='" + DdlRoleName.Text + "', Emp_Address ='" + TxtEmpAddress.Text + "',  Contact ='" + TxtContact.Text + "' ,Email ='" + TxtEmail.Text + "' WHERE Emp_ID='" + key.Value.ToString() + "'";
            conn.Open();
            com.ExecuteNonQuery();
            Response.Write("Record updated successfully");
            bindgrid();
            conn.Close();
        }
コード例 #2
0
        protected void AdminFormView_ItemInserting(object sender, FormViewInsertEventArgs e)
        {
            DataKey      key           = AdminFormView.DataKey;
            TextBox      TxtEmpName    = (TextBox)AdminFormView.FindControl("TxtEmpName");
            DropDownList DdlRoleName   = (DropDownList)AdminFormView.FindControl("DdlRoleName");
            TextBox      TxtEmpAddress = (TextBox)AdminFormView.FindControl("TxtEmpAddress");

            TextBox TxtContact = (TextBox)AdminFormView.FindControl("TxtContact");
            TextBox TxtEmail   = (TextBox)AdminFormView.FindControl("TxtEmail");


            TextBox TxtDepartment  = (TextBox)AdminFormView.FindControl("TxtDepartment");
            TextBox TxtDesignation = (TextBox)AdminFormView.FindControl("TxtDesignation");

            SqlConnection conn = new SqlConnection(connStr);

            com.Connection  = conn;
            com.CommandText = "INSERT INTO EMPLOYEE_DETAILS (Emp_Name,Emp_Address,Email,Contact,Department,Role,Designation)Values('" + TxtEmpName.Text + "','" + TxtEmpAddress.Text + "' ,'" + TxtEmail.Text + "','" + TxtContact.Text + "','" + TxtDepartment.Text + "' ,'" + DdlRoleName.Text + "','" + TxtDesignation.Text + "')";
            conn.Open();
            com.ExecuteNonQuery();
            Response.Write("Record inserted successfully");
            bindgrid();
            conn.Close();
        }