我真的很希望有人能帮助我,因为我完全搞不清楚该怎么做。这就是我现在所拥有的MVC3,剃刀,Html.DropDownListFor和选择列表
控制器:
ViewBag.TrialTopic = _trialTopicTable.GetAll(u => u.PartitionKey == PartitionKey);
return View(_dataTable.Get(u => u.PartitionKey == PartitionKey & u.RowKey == RowKey););
}
模型试验台
[DisplayName("Partition Key")]
public override string PartitionKey { get; set; }
[DisplayName("Row Key")]
public override string RowKey { get; set; }
....
public string TopicDescription { get; set; }
...
为主题表型号
[DisplayName("Partition Key")]
public override string PartitionKey { get; set; }
[DisplayName("Row Key")]
public override string RowKey { get; set; }
public string TopicDescription { get; set; }
查看:
@Html.DropDownListFor(model => model.Trial.TopicDescription,
new SelectList(ViewBag.TrialTopic, "TrialDescription", "TrialDescription"))
一些解释。 ViewBag.TrialTopic中返回的数据是七个试用主题,该表中的数据列名称为“试用描述”。在名为试用版的主表中,我也有“列名”“试用说明”。当视图显示我希望在下拉菜单中显示试用描述的当前值。当我从下拉列表中选择一个新值时,我希望在保存表格时将其保存起来。
我正在使用Windows Azure表存储,因此我不使用任何键将数据存储在主表中。我存储了完整的描述。
问题是,在上面的代码中,下拉列表中的值与表单之间似乎没有任何关联。我看了很多不同的例子,现在我完全糊涂了。希望有人能给我一些建议。
感谢,
曼迪
您如何阅读控制器中的表单数据? – FelixMM 2011-03-31 13:34:31