C
C#3w ago
morry329#

The app does not allow edits to the pre-existing card view contents

I have a simple webapp as per screenshot; the app loads the data from my MariaDB and displays it in the form of the card view (Property Name: asere). You can see the bottom edit button in there too. The problem is that the Edit button does not let me edit anything on this card view. The debug shows what happens in the backend as follows
public JsonResult EditUserJ(int Id) //For getting details of the selected User
{
//EditUserJ is set to 200 (ok) on devtool however the response is null as the id is set to the wrong index
try
{
var User = _context.ListingDTO_DBTable.Find(Id); //somehow it is set to Id = 0 !! wrong.
if (User != null)
{
Console.WriteLine($"Got it");
return Json(User);
}

return Json(null); //My MariaDB Datatable has no entry with the Id 0, so it simply returns null

}
catch (Exception ex)
{
return null;
}
}
public JsonResult EditUserJ(int Id) //For getting details of the selected User
{
//EditUserJ is set to 200 (ok) on devtool however the response is null as the id is set to the wrong index
try
{
var User = _context.ListingDTO_DBTable.Find(Id); //somehow it is set to Id = 0 !! wrong.
if (User != null)
{
Console.WriteLine($"Got it");
return Json(User);
}

return Json(null); //My MariaDB Datatable has no entry with the Id 0, so it simply returns null

}
catch (Exception ex)
{
return null;
}
}
` My Datatable only has this entry with Id = 3 as per datatable below. Does anyone have any idea why my controller (EditUserJ) accesses the Id = 0 instead of the pre-existing Id 3?? I guess this wrong access caused my Edit button to be not functional as I wanted. +-----------+-------------+-------------------+------------+------------+ | ListingId | ListingName | ListingProjectsId | CategoryId | LocationId | +-----------+-------------+-------------------+------------+------------+ | 3 | asere | 6 | 0 | 0 | +-----------+-------------+-------------------+------------+------------+ My full code for your reference https://pastebin.com/frwuc0dx
Pastebin
/* Edit View*/@model IEnumerable@{ ViewData["Titl - Pastebin.com
Pastebin.com is the number one paste tool since 2002. Pastebin is a website where you can store text online for a set period of time.
No description
1 Reply
Sehra
Sehra3w ago
where do you get $("#IdEdit") from?

Did you find this page helpful?