1
我在我的頁面上有DropDownList
和Textbox
。 DropDownList
節目從DataBase(Table "List").
數據當我在DropDownList
選擇一條線我希望看到它在Textbox
,進行修改和該行存入DataBase(Table "Text")
按「OK」後。從DropDownList到文本框
請告訴我,該怎麼做?
代碼:
Controller.cs:
public ActionResult Create(Model model)
{
var viewModel = new ISMSViewModel
{
Model = new Model(),
};
return View(viewModel);
}
[HttpPost]
public ActionResult Create(Model model, int i)
{
try
{
sysDB.AddToActives(model);
sysDB.SaveChanges();
return RedirectToAction("Browse");
}
}
ListText.ascx:
<%: Html.EditorFor(model => model.Model, new { Lists = Model.Lists } %>
<%: Html.Label("List") %>
<%: Html.DropDownList("ListId", new SelectList(ViewData["Lists"] as IEnumerable, "ListId", "Name", Model.ListId)) %>
<%: Html.Label("TextBox") %>
<%: Html.TextBoxFor(model => model.TextBox) %>
<%: Html.ValidationMessageFor(model => model.TextBox) %>
謝謝你回答我的問題,但我無法實現我的這個項目的解決方案。你會如此善良,給我一個關於這個解決方案正在進行的簡單項目的鏈接。請不要嚴格評判,我是初學者。 – sphinx 2011-04-04 05:53:20
@sphinx你可以給我你的解決方案,我會做出改變,可以嗎? – 2011-04-04 09:56:26