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
sonal malhotra
NA
410
52k
upload image n Dispaly it using webgrid in mvc
Feb 19 2019 2:12 AM
hello everyone ,
i created profile image with name n location data. successfuly and it run in show image page but it shown error
how to do this code
show image in razor page
@model IEnumerable<Webgridexample.Models.employee1>
@{
ViewBag.Title =
"Show Images"
;
Layout =
"~/Views/Shared/_Layout.cshtml"
;
}
<!DOCTYPE html>
<html>
<head>
<meta name=
"viewport"
content=
"width=device-width"
/>
<title>Show Images</title>
@*
<link href=
"~/bootstrap-3.3.6-dist/css/bootstrap.min.css"
rel=
"stylesheet"
/>*@
@*<script src=
"~/Scripts/jquery-1.9.1.js"
></script>*@
<link href=
"~/Content/bootstrap.min.css"
rel=
"stylesheet"
/>
<script src=
"~/Scripts/jquery-1.10.2.js"
></script>
<script src=
"~/Scripts/bootstrap.min.js"
></script>
<script src=
"~/Scripts/bootstrap.js"
></script>
@*<script src=
"~/bootstrap-3.3.6-dist/js/bootstrap.js"
></script>*@
@*<script src=
"~/Scripts/bootstrap.js"
></script>*@
<link href=
"~/Content/themes/base/jquery-ui.css"
rel=
"stylesheet"
/>
@*<script src=
"~/Scripts/jquery-1.8.2.js"
></script>*@
<script src=
"~/Scripts/jquery-ui-1.8.24.js"
></script>
<script type=
"text/javascript"
>
function
ZoomImage(image) {
debugger
;
document.getElementById(
"main"
).src = image;
$(
"#popupdiv"
).dialog({
width: 600,
height: 600,
modal:
true
,
buttons: {
Close:
function
() {
$(
this
).dialog(
'close'
);
}
}
});
}
</script>
</head>
<body>
<div style=
"margin-left: 50px; margin-right: 50px; margin-top: 50px;"
>
@{
var
grid =
new
WebGrid(Model, canPage:
true
, rowsPerPage: 5);
grid.Pager(WebGridPagerModes.All);
}
@grid.GetHtml(
htmlAttributes:
new
{ id =
"gridMapping"
},
tableStyle:
"table table-bordered"
,
headerStyle:
"info"
,
footerStyle:
"info"
,
alternatingRowStyle:
"webgrid-alternating-row"
,
selectedRowStyle:
"webgrid-selected-row"
,
rowStyle:
"gridrow"
,
columns: grid.Columns
(
grid.Column(
"imagename"
,
"imagename"
,
null
, style:
"imagename"
),
grid.Column(header:
"Images"
, format:
@<text>
<img id=
"imagebtn"
onclick=
"ZoomImage('data:image/jpg;base64,@(Convert.ToBase64String(item.image))')"
src=
"data:image/jpg;base64,@(Convert.ToBase64String(item.image))"
width=
"70px"
height=
"70px"
alt=
"@item.imagename"
/>
</text>, style:
"Imagepix"
),
grid.Column(
"ename"
,
"E name"
),
grid.Column(
"designation"
,
"Designation"
),
grid.Column(
"location"
,
"location"
),
grid.Column(
"salary1"
,
"salary1"
))
)
</div>
<div id=
"popupdiv"
style=
"display: none"
>
<img id=
"main"
src=
"images/main.jpg"
>
</div>
</body>
</html>
Server Error in '/' Application.
The model item passed into the dictionary is of type 'System.Collections.Generic.List`1[<>f__AnonymousType6`6[System.String,System.Byte[],System.String,System.String,System.String,System.String]]', but this dictionary requires a model item of type 'System.Collections.Generic.IEnumerable`1[Webgridexample.Models.employee1]'.
Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code.
Exception Details: System.InvalidOperationException: The model item passed into the dictionary is of type 'System.Collections.Generic.List`1[<>f__AnonymousType6`6[System.String,System.Byte[],System.String,System.String,System.String,System.String]]', but this dictionary requires a model item of type 'System.Collections.Generic.IEnumerable`1[Webgridexample.Models.employee1]'.
Source Error:
An unhandled exception was generated during the execution of the current web request. Information regarding the origin and location of the exception can be identified using the exception stack trace below.
Reply
Answers (
1
)
How to redirect page in input button using SignalR
Error while inserting data from excel to database?