Hi Silky

I'm just getting into MVC and C# so please forgive the newbie reply.

The way I have mine setup, the partial view is either in the masterpage or
in a view.
The one in the master page doesn't consume any data, so no issue for me
there.
The ones in views, either use the same data that is in the original view
Model, or I add data to the ViewData.

So in my controller I have...

        [Authorize]
        public ActionResult edit(string urlPath, string ver = "draft")
        {
            if (urlPath != null)
            {
                // todo validation
                int id = contentRepository.GetSubWebIdFromPath(urlPath);

                //build version selection list
                List<string> verList = new List<string>();
                verList.Add("draft");
                verList.Add("live");
                // add to selection list and select item
                SelectList versionlist = new SelectList(verList, ver);
                ViewData["version_list"] = versionlist;

                // build subweb selection list, and select item
                SelectList subweblist = new
SelectList(contentRepository.FindAllSubWebs().ToList(), "intSubWebID",
"strSubWebPath", id);
                ViewData["subweb_list"] = subweblist;

                tblContent tContent =
contentRepository.GetContentByPagePath(urlPath, ver);
                if (tContent != null)
                {
                    ViewData.Model = tContent;
                }
                else
                {
                    // todo handle error;
                }
            }
            else
            {
                // todo
            }
            return View();

And in the View I have...

<div id="editversioncontrol">
        <% Html.RenderPartial("editversioncontrol", Model); %>
</div>

Then in the partial view I have...

<%= Html.DropDownList("strVersion",
(IEnumerable<SelectListItem>)ViewData["version_list"])%>

<%= Html.DropDownList("intSubwebId",
(IEnumerable<SelectListItem>)ViewData["subweb_list"])%>


HTH

Cheers

Trevor

Reply via email to