title: View Data Not Working Correctly In MVC 2
body: <p>Well  i m quite new to mvc n i have been one hell of the problem here. I want to pass data from action method using ViewData to my view. I m using Asp.net MVC 2.0 with visual studio 2008.I know how to use view data from  an action method &amp; using it in a view.</p>
  
  <pre><code>Here is what i have written in my action method : - 
  
               public ActionResult Index()
                      {
                          NorthWindEntities db = new NorthWindEntities();
                          var data = (from id in db.Orders
                                      join ordid in db.Order_Details on id.OrderID equals                  ordid.OrderID
                                      select new
                                      {
                                          orderid = id.OrderID,
                                          productid = ordid.ProductID,
                                          discount = ordid.Discount
                                      }
                                        );
                          ViewData["Data"] = data;
                          return View();
                      }
  </code></pre>
  
  <p>and here is the code in the view : - </p>
  
  <pre><code>        &lt;%foreach (var item in (IEnumerable)ViewData["Data"] )
            {
                Response.Write(item.orderId);
  
            } %&gt;
  </code></pre>
  
  <p>It is giving an error like this..</p>
  
  <blockquote>
    <p>'object' does not contain a definition for 'orderId' and no extension
    method 'orderId' accepting a first argument of type 'object' could be
    found (are you missing a using directive or an assembly reference?)</p>
  </blockquote>
  
  <p>Thanks in advance</p>