List of Objects to be used on ascx view with Inherits data already loaded MVC...

Posted by user54197 on Stack Overflow See other posts from Stack Overflow or by user54197
Published on 2010-03-29T18:45:53Z Indexed on 2010/03/29 18:53 UTC
Read the original article Hit count: 223

Filed under:
|
|
|
|

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!!!

© Stack Overflow or respective owner

Related posts about c#

Related posts about html