我不确定这是否完全可能
Currently I ve managed to display a textbox for a certain column in a webgrid, but is it at all possible to have the value that it was changed to be part of the model when it is submitted back to the controller?
也许还有另一种办法可以做到这一点吗?
我不确定这是否完全可能
Currently I ve managed to display a textbox for a certain column in a webgrid, but is it at all possible to have the value that it was changed to be part of the model when it is submitted back to the controller?
也许还有另一种办法可以做到这一点吗?
是的, 通过把它做成“ 文本” 类型输入, 并将其放入窗体中。 您可以在每行中创建一个表格( 如果后退将是一个记录) ; 或者将整个 Webgrid 放在一个表格中。 后者更狡猾, 因为您必须获得输入的正确名称 。 例如, 如果您的模型被命名为“ 我收集”, 您的文本框目标“ prop1 ”, 那么您的行可能会像这样 :
<强 > 1 强 >
<input type="text" name="mycollection[0].prop1" value="@item.prop1" />
<强 > Row2 强>
<input type="text" name="mycollection[1].prop1" value="@item.prop1" />
埃特克语
显然,这不是一个完整的答案,但我希望它有所帮助。
像这样的吗?
var grid = new WebGrid(Model, canPage: true, rowsPerPage: 20);
@grid.GetHtml(tableStyle: "table", alternatingRowStyle: "alternate", headerStyle: "header",
columns: grid.Columns(
grid.Column(columnName: "name", header: "Name", canSort: true),
grid.Column(format: @<span>@Html.TextBox("Age",@item.age)</span> ),
grid.Column(" ", " ", format: @<a href="@Url.Action("AddAge", "People", new { id = item.id, ag = age })">Add age</a>),
然后你有
public ActionResult AddAge(string id, int age = 1)
{
var peopleqry = db.People.Single(a => a.id== id);
// do somehing with your age
return RedirectToAction("Index");
}
不确定 Html. TextBox (...,
我希望它能帮上忙
I am trying to make a WebForms project and ASP.NET MVC per this question. One of the things I ve done to make that happen is that I added a namespaces node to the WebForms web.config: <pages ...
I m using ASP.NET MVC and Entity Framework. I m going to pass a complex entity to the client side and allow the user to modify it, and post it back to the controller. But I don t know how to do that ...
What I want to reach is a way to add a script and style placeholder in my master. They will include my initial site.css and jquery.js files. Each haml page or partial can then add their own required ...
let s say we have something like this public class Person { public string Name {get; set;} public Country Country {get; set;} } public class PersonViewModel { public Person Person {get; ...
I started out this morning working with my ASP.NET MVC project like normal and everything worked. I added a new class and some functions and it still worked. Then, all of a sudden, while I was ...
I have an BLL that does validation on user input then inserts a parent(PorEO) and then inserts children(PorBoxEO). So there are two calls to the same InsertJCDC. One like this=>InsertJCDC(fakePor)...
So, I have an asp.net mvc app that is being worked on by multiple developers in differing capacities. This is our first time working on a mvc app and my first time working with .NET. Our app does not ...
i have the following base controller... public class BaseController : Controller { protected override void Initialize(System.Web.Routing.RequestContext requestContext) { if (...