我的表单中有这个下拉列表,它显示了从数据库调用的名称列表。每当我选择一个并提交表单时,页面都会刷新以显示结果,并且所选值会变回空白。有没有办法在我发布表格后保留选定的值?
<li class="form-line form-line-column" id="id_22">
<label class="form-label-top" id="label_22" for="input_22"> ADMIN </label>
<div id="cid_22" class="form-input-wide">
<select name="formAssigned_To">
<option></option>
@foreach(var row in db.Query("SELECT DISTINCT Name FROM Admins")){
<option value="@row.Name">@row.Name</option>
}
</select>
</div>
</li>
我有另一个相同形式的下拉列表,这个下拉列表是静态的,因此它不会从数据库中调用,并且所选值保持不变。但是,我不能对第一个下拉菜单做同样的事情,有什么想法吗?
<li class="form-line form-line-column" id="id_22">
<label class="form-label-top" id="label_22" for="input_22"> Status </label>
<div id="cid_22" class="form-input-wide">
<select class="form-dropdown" style="width:75px" id="input_22" name="formCase_Status">
<option selected="@(Request["formCase_Status"])"></option>
<option selected="@(Request["formCase_Status"] == "In Progress")" value="In Progress"> In Progress </option>
<option selected="@(Request["formCase_Status"] == "Pending")" value="Pending"> Pending </option>
<option selected="@(Request["formCase_Status"] == "Closed")" value="Closed"> Closed </option>
</select>
</div>
</li>