This is a migrated thread and some comments may be shown as answers.

Grid Sample: "The type or namespace name 'Order' could not be found"

3 Answers 81 Views
Grid
This is a migrated thread and some comments may be shown as answers.
This question is locked. New answers and comments are not allowed.
Philip
Top achievements
Rank 1
Philip asked on 18 Dec 2009, 03:22 AM
I followed the instructions in the Help file for creating a Grid with Server binding using the VS 2008 MVC Project Template . Next I configured the application as per the Help file instructions (added a reference to the Telerik.Web.Mvc.dll, etc)  Then I dropped the Northwind Order table on the Linq to SQL design surface.  Then I  modified the Home Controller to return the results of the query on the Orders table.  The Home Controller now looks like this:



using System; 
using System.Collections.Generic; 
using System.Linq; 
using System.Web; 
using System.Web.Mvc; 
using NorthwindOrder.Models; 
 
namespace NorthwindOrder.Controllers 
    [HandleError] 
    public class HomeController : Controller 
    { 
        public ActionResult Index() 
        { 
            ViewData["Message"] = "Welcome to ASP.NET MVC!"; 
 
            return View(GetOrders()); 
        } 
 
        private IEnumerable<Order> GetOrders() 
        { 
            NorthwindDataContext northwind = new NorthwindDataContext(); 
 
            return northwind.Orders; 
        } 
 
 
        public ActionResult About() 
        { 
            return View(); 
        } 
    } 
 

Next I modified Index.aspx as per the Help file sample. See below: 




<%@ Page Language="C#" MasterPageFile="~/Views/Shared/Site.Master" Inherits="System.Web.Mvc.ViewPage<IEnumerable<Order>>" %> 
 
<asp:Content ID="indexTitle" ContentPlaceHolderID="TitleContent" runat="server"
    Home Page 
</asp:Content> 
 
<asp:Content ID="indexContent" ContentPlaceHolderID="MainContent" runat="server"
    <h2><%= Html.Encode(ViewData["Message"]) %></h2
    <p> 
        To learn more about ASP.NET MVC visit <href="http://asp.net/mvc" title="ASP.NET MVC Website">http://asp.net/mvc</a>
    </p> 
     
   <%= Html.Telerik().Grid<Order>() 
        .Name("Orders") 
        .BindTo((IEnumerable<Order>)ViewData["orders"]) 
        .Pagealbe() 
        .Sortable() 
%> 
</asp:Content> 
 
Unfortunately I get a run time error which says "The type or namespace name 'Order' could not be found
(are you missing a using directive or an assembly reference?)

Any suggestions on how to resolve this error would be appreciated.  Phiip


3 Answers, 1 is accepted

Sort by
0
Atanas Korchev
Telerik team
answered on 18 Dec 2009, 08:07 AM
Hello Philip,

The ASP.NET Compiler does not know what the namespace of the Order type is. Please import the required namespace.


Regards,
Atanas Korchev
the Telerik team

Instantly find answers to your questions on the new Telerik Support Portal.
Watch a video on how to optimize your support resource searches and check out more tips on the blogs.
0
Philip
Top achievements
Rank 1
answered on 18 Dec 2009, 02:13 PM
Hi Atanas

That resolved the issue!  Thank you very much for the quick reply.

Philip


0
Chad Whitacre
Top achievements
Rank 1
answered on 11 Jan 2010, 04:09 PM
For the record, the error is with the reference to <IEnumerable<Order>> that is added to Index.aspx. I got it to work by fully qualifying 'Order' like more-or-less so: <IEnumerable<MyProject.Models.Order>>.
Tags
Grid
Asked by
Philip
Top achievements
Rank 1
Answers by
Atanas Korchev
Telerik team
Philip
Top achievements
Rank 1
Chad Whitacre
Top achievements
Rank 1
Share this question
or