Exemplo n.º 1
0
        protected void btnupdate_Click(object sender, EventArgs e)
        {
            try
            {
                Company dpt = new Company();
                dpt.Name     = txtName.Text;
                dpt.Location = txtLocation.Text;
                dpt.ID       = Int32.Parse(hdnID.Value);
                CompanyAccess manager = new CompanyAccess();

                if (manager.Update(dpt) > 0)
                {
                    GridView1.DataSourceID = ObjectDataSource1.ID;
                    btnupdate.Visible      = false;
                    btnsave.Visible        = true;
                    lblMsg.Text            = "success";
                }
                else
                {
                    lblMsg.Text = "Failed";
                }
                GridView1.DataSourceID = ObjectDataSource1.ID;
                Clear();
            }
            catch (Exception ex)
            {
                Response.Write(@"<script language='javascript'>alert('The following errors have occurred: \n" + ex + " .');</script>");
            }
        }