I have an object list being loded from a database to a drop down list. The Model loads the data to the Controller. The aspx view includes an ascx view. The ascx view already inherits data from another Project. I cannot set my List object in the ascx page. Can this be done?
Model
...
string List = dr["example"].ToString().Trim();
int indicator = dr["ex"].ToString().Trim();
LossCauseList.Add(new LossCauses(indicator, List));
...
Controller
LossCauses test = new LossCauses();
test.GetLossCauses(LossType);
TempData["Select"] = test.LossCauseList;
return View(myData);
Partial View
...
<select id="SelectedProperty">
<% List<string> selectProperty = new List<string>();
selectProperty = TempData["Select"] as Li开发者_如何转开发st<string>;
foreach(var item in selectProperty) { %>
<option><%=item.ToString() %></option>
<% } %>
</select>
...
Partial view's List should be an actual LossCauses object. HELP!!!
Change the partial view to
List<LossCauses> selectProperty = TempData["Select"] as List<LossCauses>;
精彩评论