如何在MVC中的grid.mvc控件中添加两个按钮 [英] How to add two button in grid.mvc control in mvc
本文介绍了如何在MVC中的grid.mvc控件中添加两个按钮的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我想在一列中添加两个按钮控件.目前,我可以在一栏上添加下载"按钮.但我想在同一列中的旁边添加删除按钮以下载按钮. 请在同一点上提出建议. 我已经给出了代码.
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)}
推荐答案
RenderValueAs
的重载之一接受IHtmlString
.
因此您可以这样做:
.RenderValueAs(data => new HtmlString
(
"<button type='submit' value=''>Download</button>
<button type='button' value=''>Upload</button>"
)
);
或者您可以这样做:
.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.
这篇关于如何在MVC中的grid.mvc控件中添加两个按钮的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文