Warning: file_get_contents(/data/phpspider/zhask/data//catemap/6/asp.net-mvc-3/4.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Asp.net mvc 3 如何在ASP.NET MVC的Telerik网格中绑定图像_Asp.net Mvc 3_Telerik Grid_Telerik Mvc - Fatal编程技术网

Asp.net mvc 3 如何在ASP.NET MVC的Telerik网格中绑定图像

Asp.net mvc 3 如何在ASP.NET MVC的Telerik网格中绑定图像,asp.net-mvc-3,telerik-grid,telerik-mvc,Asp.net Mvc 3,Telerik Grid,Telerik Mvc,请让我知道如何在ASP.NET MVC的Telerik网格中将图像静态图像与所有行绑定 <%= Html.Telerik().Grid(Model.SearchResponse) .Name("SearchGrid") .Columns(columns => { //Here i need to bind a static image co

请让我知道如何在ASP.NET MVC的Telerik网格中将图像静态图像与所有行绑定

 <%= 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)
    %>

这可以通过向集合中添加另一个模板列来实现:

使用ASPX

使用剃刀

更新:如果希望绑定模型中的图像,请参考以下示例:

columns.Template(c => {
%>
<img 
alt="<%= c.CustomerID %>" 
src="<%= Url.Content("~/" + c.CustomerID + ".jpg") %>" 
/>
<%
});
或者,如果您正在使用客户端模板,请尝试以下操作:

.Columns(columns =>
{
columns.Bound(c => c.CustomerID)
.ClientTemplate("<img alt='<#= CustomerID #>' src='" 
+ Url.Content("~/") 
+ "<#= CustomerID #>.jpg' />")
.Title("Picture");
//omitted for brevity
}

这样我们可以将图像绑定到每一行。 我们还可以用这些图像添加动作

columns.Command(commands => commands.Custom("View").ButtonType(GridButtonType.BareImage)

可能是Hi Nick的副本,谢谢你的回答。@ArunGupta你还需要这个问题的帮助吗?Hey Nick,谢谢你的回答,但我仍然面临图像绑定的问题,因为我使用的是局部视图,我正在使用本地机器上的图像路径,它的错误就像无效参数一样。请您发布一个可以与MVC ASPX引擎的任何映像绑定的工作代码。@ArunGupta我添加了一个绑定示例。这就是您要找的吗?是的,这是我的要求,但当我尝试此操作时,它不是绑定图像,它只是显示来自viewModel的列值。
.Columns(columns =>
{
columns.Bound(c => c.CustomerID)
.ClientTemplate("<img alt='<#= CustomerID #>' src='" 
+ Url.Content("~/") 
+ "<#= CustomerID #>.jpg' />")
.Title("Picture");
//omitted for brevity
}
columns.Command(commands => commands.Custom("View").ButtonType(GridButtonType.BareImage)