Hi
In below code i am getting above error. I want to save only2 filenames maximum

Thanks
Hi
In below code i am getting above error. I want to save only2 filenames maximum

Thanks
Know the answer? Post it. Somebody with the same question will find it here.
Answer a question in the forums and earn +20 SHARP for every answer.
See unanswered questions
DevSocialUpcoming · 3rd editionAI Agents ConferenceDec 1–3, 2026Live onlineFree to attend5days leftRegister
Aravind GovindarajRank #430 · 5.8K reputationPosted Dec 6, 2022, 6:13 AM EST
Hi Ramco, The issue is due to the following code, the output is more than a single record. Can you please try the first / firstordefault
context.TicketAnalysis.Single(rec => rec.TicketID == Convert.ToInt32(hdfTicketId.Value));
Please let me know if still issue persists.
:)
Jignesh KumarRank #91 · 22.9K reputationPosted Dec 6, 2022, 1:35 AM EST
Hello Ramco,
Inside foreach loop you need to change if() condition as below,
if(postedFile.HasFile) { ...... ...... ...... }Ramco RamcoRank #462 · 5.4K reputationPosted Dec 6, 2022, 4:56 AM EST
Hi Jignesh
On below code i am getting same error
if (FileUpload1.HasFile) { String fileName = FileUpload1.FileName.Substring(0, FileUpload1.FileName.LastIndexOf(".")); strname = fileName + "_" + name + FileUpload1.FileName.Substring(FileUpload1.FileName.LastIndexOf("."), 4); strname = strname.Replace(':', '_').Replace('-', '_').Replace('\\', '_').Replace('/', '_').Replace(' ', '_').Replace('+', '_').Replace('&', '_').Replace('@', '_').Replace('#', '_'); FileUpload1.SaveAs(Server.MapPath(FolderPath) + strname); String ext = System.IO.Path.GetExtension(FileUpload1.FileName); TicketAnalysi objUpload = context.TicketAnalysis.Single(rec => rec.TicketID == Convert.ToInt32(hdfTicketId.Value)); { objUpload.Attachment1 = strname; context.TicketAnalysis.InsertOnSubmit(objUpload); context.SubmitChanges(); }; }Thanks