0

I have a web grid that I want to display an image instead of the word "delete"

instead of this "Html.ActionLink("Delete"," I want to put an image

how can I do it?

this is my code:

enter code here

               @{ var grid = new WebGrid(source: Model.PartImageSearchResult, rowsPerPage: 2, canPage: true, defaultSort:
                       "PartImageSearchResult.PartImageName", canSort: true, ajaxUpdateContainerId: "ImagesListGrid");}

                    @grid.GetHtml(
                    mode: WebGridPagerModes.All,
                    numericLinksCount: 5,
                    firstText: "First",
                    lastText: "Last",
                    previousText: "Previous",
                    nextText: "Next",
                    tableStyle: "webgrid",
                    headerStyle: "webgrid-header",
                    rowStyle: "webgrid-row-style",
                    footerStyle: "webgrid-footer",
                    alternatingRowStyle: "webgrid-selected-row",
                     htmlAttributes: new { id = "PartFilesUploadID" },
                    columns: grid.Columns(



                    //grid.Column(style: "PartImagesDelete", format: (item) => Html.ImageLink("~/Content/images/btn_delete_sm.png", "DeletePartImages", new { id = item.PartFilesUploadID }, new { onclick = "return confirm('Are you sure you wish to delete this article?');" })),


                    grid.Column(style: "PartImagesDelete", format: (item) => Html.ActionLink("Delete", "DeletePartImages", new { id = item.PartFilesUploadID }, new { onclick = "return confirm('Are you sure you wish to delete this article?');" })),
                    grid.Column(header: "Images", style: "PartImages", format: @<text><img src="@Url.Content("~/Uploads/Parts/" + item.PartImageName)" alt="" style="width:100px;height:50px;" /></text>),
                    grid.Column(header: "Files Name", format: @<text>@((item.PartImageName as String))</text>)))
tereško
  • 58,060
  • 25
  • 98
  • 150
user1361209
  • 1
  • 1
  • 1

2 Answers2

0

I would look here Action Image MVC3 Razor

Whether your action is in a grid or not should not matter. If necessary you can wrap a partial around the custom action link that takes your specific model.

Community
  • 1
  • 1
Nick
  • 6,366
  • 5
  • 43
  • 62
  • I want to do something like this: – user1361209 Apr 27 '12 at 15:07
  • grid.Column(style: "PartImagesDelete", format: (item) => Html.Action("~/Content/images/btn_delete_sm.png", "DeletePartImages", new { ImageID = item.PartFilesUploadID }, new { onclick = "return confirm('Are you sure you wish to delete this article?');" })), – user1361209 Apr 27 '12 at 15:07
  • I want to use this image "~/Content/images/btn_delete_sm.png" – user1361209 Apr 27 '12 at 15:08
  • If you implemented this first: [link](http://stackoverflow.com/a/9899328/1048369) You could then do: – Nick Apr 29 '12 at 14:50
  • grid.Column(style: "PartImagesDelete", format: (item) => Html.ImageActionLink("~/Content/images/btn_delete_sm.png", "DeletePartImages", new { ImageID = item.PartFilesUploadID }, new { onclick = "return confirm('Are you sure you wish to delete this article?');" })) – Nick Apr 29 '12 at 14:53
0
grid.Column("", header: "Acciones", style:"width: 5%", 
                                    format: @<text>
                                                <div class="btn-group">
                                                    <a class="btn btn-small" href='@Url.Action("Editar", "Ruta", new { id = item.RutaID })'><i class="icon-pencil"></i></a>
                                                    <a class="btn btn-small" href='@Url.Action("Detalle", "Ruta", new { id = item.RutaID })'><i class="icon-eye-open"></i></a>
                                                    <a class="btn btn-small" href='@Url.Action("Borrar", "Ruta", new { id = item.RutaID })'><i class="icon-trash"></i></a>                                                                            
                                                </div>
                                            </text>)