title: How to access PageData defined in the parent view in partial view?
body: <p>I am trying to access the PageData defined in the view in the partial view. I am able to access it if I pass the PageData as a model to the Partial view. I don't like this approach as it is not the model for the view.
  Partial view will have its own instance of PageData. So is there a way to access the Parent's ViewData?
  Here is the sample code...
  View Code</p>
  
  <pre><code>@{
      ViewBag.Title = "Home Page";
      PageData["MyName"] = "Sathi";
  }
  &lt;h2&gt;@ViewBag.Message&lt;/h2&gt;
  &lt;h3&gt;@WebPageContext.Current.Page.PageData.Count()&lt;/h3&gt;
  &lt;h3&gt;@PageData["MyName"]&lt;/h3&gt;
  &lt;h3&gt;@WebPageContext.Current.Page.PageData.Count()&lt;/h3&gt;
  @{ Html.RenderPartial("_Partial"); }
  Parent view ends here
  </code></pre>
  
  <p>Partial view code</p>
  
  <pre><code>This is a partial view
  &lt;h3&gt;@PageData["MyName"]&lt;/h3&gt;&lt;-- Empty
  &lt;h3&gt;@WebPageContext.Current.Page.PageData.Count()&lt;/h3&gt;
  </code></pre>