Beginner problem:
I have some data in a database, and I select one row from it using the code line:
Whenever I select entire table, I use
However in the above case I can not use the same method. I can also see that
Is there a direct way to put this data in corresponding view. Any help is highly appreciated
I have some data in a database, and I select one row from it using the code line:
C#:
var ItemInDb = _context.ItemInDb.Find(id);
Whenever I select entire table, I use
ToList()
at the end of the line instead of Find(id)
, use ViewBag
and then I can use foreach
loop to display the table.However in the above case I can not use the same method. I can also see that
ItemInDb
does actually contain all the data from corresponding row.Is there a direct way to put this data in corresponding view. Any help is highly appreciated