It's me c# code . I have get value from database using this code.Run this code but view only one record.
public IActionResult UserManagement()
{
UserViewModel obj = new UserViewModel();
List lst = new List();
try
{
var Result = _context.UserProfileMaster.ToList();
if (Result.Count > 0)
{
foreach (var item in Result)
{
obj.FullName = item.FirstName + " " + item.LastName;
obj.DOB = Convert.ToDateTime(item.Dob);
var Mob = item.MobileNumber;
obj.MobileNumber = String.Format("{0:+##-##########}", double.Parse(Mob));
obj.Country = item.Country;
obj.UserImage = item.UserImage;
}
}
else
{
ViewBag.message = "No Record !";
}
}
catch (Exception ex)
{
ViewBag.message = "Internal Server Error";
var message = ex.InnerException.Message;
throw;
}
return View(new List { obj });
}
It's me view code.
@foreach (var item in Model)
{
4 Replies
Know the answer? Post it — somebody with the same question will find it here.
Sign in to answer this question
It is the same account you read, post and publish with — and you will come straight back to this page.
Jenith ThakkarPosted Jul 15, 2020, 10:16 AM
foreach (var item in Result)
Jenith ThakkarPosted Jul 16, 2020, 1:57 AM
so it's overight value everytime
That's why you have to do something like
Posted Jul 16, 2020, 1:46 AM
Jignesh KumarPosted Jul 15, 2020, 8:56 AM