views:

39

answers:

1

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 List<string>;
           foreach(var item in selectProperty) { %>
                <option><%=item.ToString() %></option>
           <% } %>
         </select>
         ...

Partial view's List should be an actual LossCauses object. HELP!!!

+1  A: 

Change the partial view to

List<LossCauses> selectProperty = TempData["Select"] as List<LossCauses>;
SLaks