我有这样的看法:
<%= Html.Grid(Model.data).Columns(column => {
column.For(x => x.results)
.Action(item => Html.ActionLink(item.results,"Edit").ToString(),
item => Html.TextBox("result",item.results).ToString(),
item => (Model.data == item))
.Named("Results");
column.For(x => x.refId)
.Named("Reference ID");
column.For(x => x.fileLocation)
.Named("File Location");
})
.Attributes(style => "width:100%", border => 1)
控制器看起来像:
public ActionResult Index()
{
// IEnumerable<TranslationResults> results;
StringSearchResultsModelIndex modelInstance = new StringSearchResultsModelIndex();
modelInstance.getData();
return View("SearchGUIString", modelInstance);
}
数据:
public class StringSearchResultsModelIndex : IStringSearchResultsModelIndex
{
private IEnumerable<StringSearchResultModel> m_data;
private string id;
public IEnumerable<StringSearchResultModel> getData()
{
List<StringSearchResultModel> models = new List<StringSearchResultModel>();
StringSearchResultModel _sModel = new StringSearchResultModel();
for (int i = 1; i < 11; i++)
{
_sModel = new StringSearchResultModel();
_sModel.fileLocation = "Location" + i;
_sModel.refId = "refID" + i;
_sModel.results = "results" + i;
models.Add(_sModel);
}
m_data = models;
return models;
}
public IEnumerable<StringSearchResultModel> data { get { return m_data; } set { m_data = value; } }
public string SelectedRowID {get {return id ; } set { id = value; } }
}
当我单击 ActionLink 中的编辑按钮时,我被定向到 /search/Edit 页面,我知道我需要在控制器中有一些代码用于 //search/Edit 但我没有得到可以编辑文本的文本框在结果单元格中。我是 MVC 的新手,任何人都可以指导我从这里去哪里,有什么建议吗?