Team Binary
New Member
Thanks for looking at my question in advanced.I am trying to update information in a database from a save button.At the moment I have got it saving, but it saves the update as a new row.I have got the ID of the row that I wish to change but I am struggling to get it to work.ASP.NET:\[code\]<asp:Button runat="server" ID="btnSave" CssClass="btnSubmit" Text="Save" OnClick="btnSave_Click" />\[/code\]C#:\[code\]protected void btnSave_Click(object sender, EventArgs e){ int ItemID = 0; var Item = Placements.GetPlacementByExpiry(ItemID, false); if (Item == null) { Item = new Placements(); } Item.CategoryID = Convert.ToInt32(ddlCategory.SelectedValue); Item.Title = txtTitle.Text; Item.Company = txtCompany.Text; Item.Location = txtLocation.Text; Item.Duration = txtDuration.Text; Item.SalaryFrom = Convert.ToDecimal(txtSalaryFrom.Text); Item.SalaryTo = Convert.ToDecimal(txtSalaryTo.Text); Item.SalaryType = ddlSalaryType.Text; Item.Description = txtDescription.Text; Item.Responsibilities = txtResponsibilities.Text; Item.Requirements = txtRequirements.Text; DateTime ExpiryDate = DateTime.ParseExact(txtExpiryDate.Text, "dd/MM/yyyy", System.Globalization.CultureInfo.InvariantCulture); Item.ExpiryDate = ExpiryDate; Item.DateCreated = DateTime.Now; if (Item.ID == 0) { Placements.CreatePlacement(Item); } else { Placements.UpdatePlacement(Item); } mvEdit.SetActiveView(vwList);}\[/code\]I have tried putting a command argument on the button and changed it in the back end, but receive the following error:\[code\]Error 1 No overload for 'btnSave_Click' matches delegate 'System.EventHandler' C:\Users\laura\Documents\Visual Studio 2010\WebSites\ThirdYearProject\tools\controls\placements\edit.ascx 239\[/code\]I've been trying to fix it for a while now but I'm not sure what I'm doing wrong! Any help would be appreciated.