问题
I want to add two button control in one column. currently i can able to add Download button on one column . but i want to add delete button beside to download button in same columns. please suggest on the same. I have given code..
@using (Html.BeginForm("DownloadFile", "Download", FormMethod.Post))
{
@Html.Grid(Model).Columns(columns =>
{
columns.Add()
.Encoded(false)
.Sanitized(false)
.SetWidth(0)
.RenderValueAs(o => @<input id="id" name="IsChecked" value= @o.id , type="checkbox"/>);
columns.Add(data => data.FileName).Titled("File Name").SetWidth(50);
columns.Add(data => data.DisplayedDate).Titled("Uploaded Date").SetWidth(40);
columns.Add(data => data.User_Name).Titled("User Name").SetWidth(50);
columns.Add()
.Encoded(false)
.Sanitized(false)
.SetWidth(80)
.RenderValueAs(data => @<button type="submit" value ="">Download</button>);
}).WithPaging(10).Sortable(true).Filterable(true)}
回答1:
One of the overload for RenderValueAs
accepts IHtmlString
.
So you can do:
.RenderValueAs(data => new HtmlString
(
"<button type='submit' value=''>Download</button>
<button type='button' value=''>Upload</button>"
)
);
Or you can do:
.RenderValueAs(data => "<button type='submit' value=''>Download</button>
<button type='button' value=''>Upload</button>"
);
If you need more control, there is a Custom Layout rendering feature that you can use.
回答2:
columns.Add(c => c.PrecioVenta).Titled("Precio de Venta").Filterable(true);
columns.Add(c => c.Cantidad).Titled("Cantidad").Filterable(true);
columns.Add()
.Encoded(false)
.Sanitized(false)
.SetWidth(30)
.RenderValueAs(o => Html.ActionLink("Editar", "Edit", new { id = o.IdProducto }, new { @class = "btn btn-primary" }));
columns.Add()
.Encoded(false)
.Sanitized(false)
.SetWidth(30)
.RenderValueAs(o => Html.ActionLink("Detalles", "Details", new { id = o.IdProducto }, new { @class = "btn btn-info" }));
来源:https://stackoverflow.com/questions/33492845/how-to-add-two-button-in-grid-mvc-control-in-mvc