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
127k
Error in mvc view.
Aug 1 2020 6:13 AM
it's my data get code in mvc when page reload.
public
IActionResult EducationalVideo()
{
List<EducationalVideoViewModel> lst =
new
List<EducationalVideoViewModel>();
try
{
var Video = _context.TblEducationalVideo.ToList();
if
(Video !=
null
)
{
foreach
(var item
in
Video)
{
EducationalVideoViewModel lst_Data =
new
EducationalVideoViewModel();
lst_Data.Name = item.Name;
lst_Data.Video = item.VideoPath;
lst.Add(lst_Data);
}
}
else
{
ViewBag.message =
"No Record !"
;
}
}
catch
(Exception ex)
{
ViewBag.message =
"Internal Server Error"
;
var message = ex.InnerException.Message;
throw
;
}
return
View(lst);
}
it's me viewmodel classes
public
class
EducationalVideoViewModel
{
public
string
Name {
get
;
set
; }
public
string
Video {
get
;
set
; }
}
public
class
EducationalVideoList
{
public
List<EducationalVideoViewModel> lst_EducationData {
get
;
set
; }
public
string
Name {
get
;
set
; }
public
string
Video {
get
;
set
; }
public
string
Image {
get
;
set
; }
}
it's view code
@foreach (
var
item
in
Model.lst_EducationData)-Here i have face issue
null
value.
{
<tr
class
=
"Search"
>
<td>@{ Srno++; } @Srno </td>
<td>
<div
class
=
"video-frame"
>
<video width=
"200"
height=
"140"
controls>
<source src=
"http://nbpbaseball.harishparas.com/UploadVideo/@Url.Content(item.Video)"
type=
"video/mp4"
>
</video>
</div>
</td>
<td>@Html.DisplayFor(x => item.Name)</td>
<td>
<a href=
"#"
class
=
"btn btn-danger"
><i
class
=
"fa fa-trash"
></i> Delete</a>
</td>
</tr>
}
Reply
Answers (
2
)
Events example - beers in the fridge
Used .NET Core for a while? What are your thoughts about it?