我的观点:
<%= 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的从编辑按钮,我指向/搜索/编辑页面,我明白我必须控制器//查找/编辑一些代码,但我没有得到的文本框,我可以编辑文本在结果单元格。 我是新来的MVC任何人都可以直接我在哪里,我应该从这里去,有什么建议?