我有一个多重搜索查询,其中包括一个下拉菜单,用于选择需要从我的 RMS 数据库中的 Assigned_To 列调用的管理员。问题是下拉列表显示了每个重复的值。例如:
管理员:
未分配
未分配
"
"
"
Alexandra M.
Martin D.
Alexandra M.
我希望它看起来像:
管理员:
未分配
Martin D.
Alexandra M.
“未分配”是创建案例的默认值。
这是我的代码:
var db = Database.Open("RMS") ;
var selectCommand = "SELECT * FROM RMS";
var formSSO = "";
var formAssigned_To = "";
var formCase_Status= "";
var fromDate = "";
var toDate = "";
formSSO = Request.QueryString["formSSO"];
formAssigned_To = "%" + Request["formAssigned_To"] + "%";
formCase_Status = Request["formCase_Status"];
fromDate = Request.QueryString["fromDate"];
toDate = Request.QueryString["toDate"];
selectCommand = "SELECT DISTINCT * FROM RMS WHERE 1=1";
if(!Request.QueryString["formSSO"].IsEmpty() ) {
selectCommand +=" AND SSO LIKE @0";
}
if(!Request.QueryString["formAssigned_To"].IsEmpty() ) {
selectCommand +=" AND Assigned_To LIKE @1";
}
if(!Request.QueryString["formCase_Status"].IsEmpty() ) {
selectCommand +=" AND Case_Status = @2";
}
if(!Request.QueryString["fromDate"].IsEmpty() ) {
selectCommand +=" AND Created >= @3";
}
if(!Request.QueryString["toDate"].IsEmpty() ) {
selectCommand +=" AND Created <= @4";
}
var data = db.Query(selectCommand, formSSO, formAssigned_To, formCase_Status, fromDate, toDate);
var columns = new[]{"ID", "SSO", "Category", "System", "Subject", "Created", "Assigned_To"};
var grid = new WebGrid(data, ajaxUpdateContainerId: "grid", defaultSort: "ID", columnNames: columns);
if (Request.QueryString[grid.SortDirectionFieldName].IsEmpty()) {
grid.SortDirection = SortDirection.Descending;
}
}
这是下拉列表的 html 表单字段:
<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">
@foreach(var row in data){
<option></option>
<option value="@row.ID">@row.Assigned_To</option>
}
</select>
</div>
</li>