I was writing different type of code from Google but it is not display correct value in the dropdown. It shows the correct value in the textbox but not selected value in the dropdown.
Model
public Int64 EvaluationInfoID { get; set; }
public Int64 EvalCategoryID { get; set; }
public string EvalCategoryName { get; set; }
public string EvalCategoryDesc { get; set; }
public Int64 UserID { get; set; }
public DateTime? EvaluationDate { get; set; }
public int EvalTypeID { get; set; }
Controller
var models = new List<EvaluationInfoViewModel>();
ViewBag.GridState = this.GridRouteValues();
string serachCriteria = string.Format("created_by={0} and to_date(to_char(evaldate,'MM/DD/YYYY'),'MM/DD/YYYY')={1} ", Convert.ToInt32(Session["UserID"]), "to_date('" + evaldate.ToShortDateString() + "','MM/DD/YYYY')");
PODService.EvaluationInfo[] getData = service.GetEvaluationInfoBySearchCriteria(serachCriteria);
PODService.EvaluationCategory[] evalcat = service.GetEvalCategoryBySearchCriteria(" EC.Eval_ID= 1");//150811VP: For Self Evaluation Eval_ID=1
PODService.EvaluationType[] evalTypes = service.GetEvaluationTypeList();
ViewData["EVALTYPE"] = new SelectList(evalTypes, "EvaluationType_ID", "EvaluationType_Name");
for (var i = 0; i < getData.Length; i++)
{
models.Add(new EvaluationInfoViewModel());
}
for (var i = 0; i < models.Count; i++)
{
string serachCriteria1 = string.Format("created_by={0} and to_date(to_char(evaldate,'MM/DD/YYYY'),'MM/DD/YYYY')={1} ", Convert.ToInt32(Session["UserID"]), "to_date('" + evaldate.ToShortDateString() + "','MM/DD/YYYY')");
models[i].EvalCategoryID = getData[i].EvalCategory_ID;
models[i].EvalCategoryName = getData[i].EvalCategoryName;
//models[i].EvalCategoryDesc = getData[i].Eval_CategoryDescription;
models[i].UserID = Convert.ToInt64(Session["UserID"]);
models[i].EvaluationDate = getData[i].EvaluationDate;
models[i].EvalTypeID = getData[i].EvalTypeID;
ViewData["EVALTYPEInfo"] = new SelectList(evalTypes, "EvaluationType_ID", "EvaluationType_Name", models[i].EvalTypeID);
View
@model List<PODWeb.Models.EvaluationInfoViewModel>
@{
Layout = null;
}
@using (Html.BeginForm("EditEvaluationInfo", "EvaluationInfo", FormMethod.Post))
{
<table border="1px" style="margin-left: 122px">
<tr>
<td>
<table>
@for (var i = 0; i < Model.Count(); i++)
{
@Html.HiddenFor(m=>m[i].UserID)
@Html.HiddenFor(m=>m[i].EvaluationDate)
@Html.HiddenFor(m =>m[i].EvalTypeID)
<tr>
<td>
@Model[i].EvalCategoryName
@Html.EditorFor(m =>m[i].EvalTypeID)
</td>
<td>
@*@Html.DropDownListFor(m => m[i].EvalTypeID, ViewData["EVALTYPEInfo"] as IEnumerable<SelectListItem>, "Select Rating", new { @style = "width:200px" })*@
</td>
</tr>
<tr>
<td>
@Model[i].EvalCategoryDesc
@Html.HiddenFor(m => m[i].EvalCategoryID)
</td>
<td>
</td>
</tr>
<tr>
<td colspan="2">
<hr />
</td>
</tr>
}
<tr>
<td>
<input type="submit" name="Save" value="Save" class="t-button" style="margin-left: 471px" />
</td>
</tr>
</table>
</td>
</tr>
</table>
}
I want to display selected evaltypeid in dropdownlist but it is not displaying.