您好我正在使用MVC3我希望将前端显示的值插入到后端的表中。我能实现这个目标吗?
以下是我的观点,
@model TravelReady_SupervisorInput.Models.TravelReadyModel
@{
Layout = "~/Views/Shared/_Layout.cshtml";
}
<script language="javascript">
$(document).ready(function () {
$("#es").hide();
$("#n").hide();
$("#date").hide();
});
</script>
<h2 class="filter">Associate Details</h2>
<fieldset class="fs">
@foreach (var item in Model.lstTravelReadyEntities)
{
<label class="Detail1"><b>Associate Id : </b>@item.Var_AssoId </label>
<label class="Detail1"><b>Vertical :</b>@item.Var_Vertical</label>
<label class="Detail1"><b>Visa ValidFrom :</b>@item.Dt_VisaValidFrom </label><br /><br />
<label class="Detail2"><b>Associate Name :</b>@item.Var_AssociateName</label>
<label class="Detail2"><b>Account Name :</b>@item.Var_AccountName</label>
<label class="Detail2"><b>Visa ValidDate :</b>@item.Dt_VisaValidTill</label><br /><br />
<label class="Detail3"><b>Grade HR :</b>@item.Var_Grade</label>
<label class="Detail3"><b>Project Name :</b>@item.Var_Project_Desc</label><br />
}
<h2> Response Details</h2><br />
Supervisor Response :
<input type="radio" class="radi" name="radio" value="Yes" onclick="javascript:Getyfunc();">Yes
<input type="radio" name="radio" value="No" onclick="javascript:Getnfunc()">No
<div id="es">
<label style="padding-left:10px;">*Supervisor Inputs :
<select id="dropdown" name="dropdown">
<option value="0">Select</option>
<option value="1">Available for Deployment/Release</option>
<option value="2">Travel Planned</option>
<option value="3">To Deploy For Same Account</option>
</select>
</label>
<label>Comments If Any
<textarea name="comments" id="cmts"></textarea>
</label>
<br />
<br />
<label id="date">*Date of Travel
<input type="text" id="datepicker" onclick="$(this).datepicker().datepicker ('show')"/>
</label>
<br />
<br />
</div>
<div id="n">
<label style="padding-left:10px;">*Supervisor Inputs :
<select id="dropdown" name="dropdown">
<option value="0">Select</option>
<option value="1">Critical Project Resource</option>
<option value="2">Associate Unwilling to Travel</option>
</select>
</label>
<label>Comments If Any
<textarea name="comments" id="cmts"></textarea></label>
<br />
<br />
</div>
<input type="submit" id="sbt" value="Submit" name="Submit" onclick="javascript:InsertDetails();"/>
</fieldset>
这是页面的子窗口。我也在使用局部视图。我想获取页面中显示的所有值,以便插入到table.can任何人都可以帮我解决这个问题< / p>
答案 0 :(得分:1)
您应该为视图创建一个ViewModel,用于存储您希望传递给控制器的模型和其他数据,例如Supervisor响应和注释。利用MVC扩展,如EditorFor,TextAreaFor等
答案 1 :(得分:0)
好的,你在这里只是模型 - 视图 - 控制器的View部分。您似乎有一个ViewModel列表显示在页面上,但您仍然缺少一些关键部分:
你需要在这里做很多研究,但这应该让你开始。这是一个很棒的综合教程,将引导您完成上述所有内容! http://www.asp.net/mvc/tutorials/getting-started-with-ef-using-mvc/creating-an-entity-framework-data-model-for-an-asp-net-mvc-application