如何绑定在Telerik的网格ASP.NET MVC的图像 [英] How to bind images in Telerik Grid for ASP.NET MVC
本文介绍了如何绑定在Telerik的网格ASP.NET MVC的图像的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
请让我知道如何将图像静态图像的结合与ASP.NET MVC Telerik的中网格的所有行。
<%= Html.Telerik()网格(Model.SearchResponse)
。名称(SearchGrid)
.Columns(列=>
{
//这里我需要一个静态图像列绑定// columns.Bound(格=> grid.Name);
columns.Bound(格=> grid.CaseNumber);
})
.Pageable(真)
%GT;
解决方案
这是可以通过增加另一个模板列到您的收藏:
使用ASPX
columns.Template(C => {
%GT;< IMG ALT =静态图片ALT textSRC =<%= Url.Content(〜/ myImage.jpg这个参数)%GT;
/><%
})标题(静态图像)。
使用剃刀
columns.Template(
@<文字和GT;
< IMG ALT =静态图片ALT textSRC =@ Url.Content(〜/ myImage.jpg这个参数)/>
< /文字和GT;
).title伪(静态图像);
更新:如果您希望从你的模型绑定图片,请参考下面的例子:
columns.Template(C => {
%GT;
< IMG
ALT =&下;%= c.CustomerID%gt;中
SRC =<%= Url.Content(〜/+ c.CustomerID +.JPG)%>中
/>
<%
});
或者,如果你使用的客户端模板,请尝试以下操作:
.Columns(列=>
{
columns.Bound(C => c.CustomerID)
.ClientTemplate(< IMG ALT ='<#=#客户ID>'SRC ='
+ Url.Content(〜/)
+<#=#客户ID> .JPG/>中)
.title伪(图片);
//为简洁起见省略
}
Please let me know how to bind a image static image with all rows in Telerik Grid for ASP.NET MVC.
<%= Html.Telerik().Grid(Model.SearchResponse)
.Name("SearchGrid")
.Columns(columns =>
{
//Here i need to bind a static image column//
columns.Bound(grid => grid.Name);
columns.Bound(grid => grid.CaseNumber);
})
.Pageable(true)
%>
解决方案
This is possible by adding another templated column to your collection:
Using ASPX
columns.Template(c => {
%><img alt="Static Image Alt Text" src="<%= Url.Content("~/myImage.jpg") %>"
/><%
}).Title("Static Image");
Using Razor
columns.Template(
@<text>
<img alt="Static Image Alt Text" src="@Url.Content("~/myImage.jpg") " />
</text>
).Title("Static Image");
UPDATE: If you wish to bind images from your model, please refer to the following example:
columns.Template(c => {
%>
<img
alt="<%= c.CustomerID %>"
src="<%= Url.Content("~/" + c.CustomerID + ".jpg") %>"
/>
<%
});
Or if you're using client templates, try the following:
.Columns(columns =>
{
columns.Bound(c => c.CustomerID)
.ClientTemplate("<img alt='<#= CustomerID #>' src='"
+ Url.Content("~/")
+ "<#= CustomerID #>.jpg' />")
.Title("Picture");
//omitted for brevity
}
这篇关于如何绑定在Telerik的网格ASP.NET MVC的图像的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文