Updating information by ID in a database - ASP.NET/C# -
thanks looking @ question in advanced.
i trying update information in database save button.
at moment have got saving, saves update new row.
i have got id of row wish change struggling work.
asp.net:
<asp:button runat="server" id="btnsave" cssclass="btnsubmit" text="save" onclick="btnsave_click" />
c#:
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); }
i have tried putting command argument on button , changed in end, receive following error:
error 1 no overload 'btnsave_click' matches delegate 'system.eventhandler' c:\users\laura\documents\visual studio 2010\websites\thirdyearproject\tools\controls\placements\edit.ascx 239
i've been trying fix while i'm not sure i'm doing wrong! appreciated.
i think item.id == 0 not 0 either null or other values. please check value of that.
Comments
Post a Comment