TECHNOLOGIES
FORUMS
JOBS
BOOKS
EVENTS
INTERVIEWS
Live
MORE
LEARN
Training
CAREER
MEMBERS
VIDEOS
NEWS
BLOGS
Sign Up
Login
No unread comment.
View All Comments
No unread message.
View All Messages
No unread notification.
View All Notifications
Answers
Post
An Article
A Blog
A News
A Video
An EBook
An Interview Question
Ask Question
Forums
Monthly Leaders
Forum guidelines
Guest User
Tech Writer
611
127.8k
Get Only Single Value Error
Jul 15 2020 8:05 AM
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<UserViewModel> lst = new List<UserViewModel>();
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<UserViewModel> { obj });
}
It's me view code.
<tbody>
@foreach (var item in Model)
{
<tr>
<td>1.</td>@*<img src="@Url.Content(Model.ImagePath)" alt="Image" />*@
<td><img src="@Url.Content(item.UserImage))" alt="image">@Html.DisplayFor(x => item.FullName)</td>
<td>@Html.DisplayFor(x => item.DOB)</td>
<td>@Html.DisplayFor(x => item.MobileNumber)</td>
<td>@Html.DisplayFor(x => item.Country)</td>
<td><a href="" class="btn btn-primary">View Detail</a></td>
</tr>
check this
Reply
Answers (
4
)
asp.net web application complilation
How to get employee details using stored procedure in oracle database