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
أماني مفيد
NA
142
17.4k
error in return view MVC
Sep 29 2020 6:31 AM
i have this controller :
public
ActionResult search(
int
? page,
string
search ,
string
KEYWORD_NAME)
{
if
(search ==
null
)
{
Bindkeyword();
return
View();
}
else
{
KEYWORD_NAME = Request.QueryString[
"Contant.KEYWORD_NAME"
];
Bindkeyword();
DataSet dst =
new
DataSet();
dst.Tables.Add(op.search(search, KEYWORD_NAME));
List<ContantViewModel> seaech =
new
List<ContantViewModel>();
foreach
(DataRow dr
in
dst.Tables[0].Rows)
{
ContantViewModel u =
new
ContantViewModel();
u.articalname = dr[
"ARTICAL_NAME"
].ToString();
u.articalbody = dr[
"ARTICALBODY"
].ToString();
u.userName = dr[
"IUSER"
].ToString();
u.articlid = dr[
"ARTICL_ID"
].ToString();
seaech.Add(u);
}
if
(seaech.Count > 0)
{
op.addsearch(search, KEYWORD_NAME);
return
View(seaech.ToPagedList(page ?? 1, 10));
}
else
{
ContantViewModel u =
new
ContantViewModel();
u.s =
"there is no data "
;
u.s1 =
"e.jpg"
;
seaech.Add(u);
return
View(seaech.ToPagedList(page ?? 1, 10));
}
}
}
and this is the view
i use this model :@model Wiki_Reach_Site.Models.ContantViewModel
i have error in the line in BOLD
this is the error
System.InvalidOperationException: The model item passed into the dictionary is of type 'PagedList.PagedList`1[Wiki_Reach_Site.Models.ContantViewModel]', but this dictionary requires a model item of type 'Wiki_Reach_Site.Models.ContantViewModel'.
how i can fix it ?
Reply
Answers (
9
)
while Importing csv file to sql table it gives error
Implement foreachloop in mvc