2 Replies - 3357 Views - Last Post: 30 August 2012 - 09:55 AM Rate Topic: -----

#1 rbflowers  Icon User is offline

  • New D.I.C Head

Reputation: 2
  • View blog
  • Posts: 48
  • Joined: 10-February 12

Compilation error: CS0103: The name 'grid' does not exist in

Posted 29 August 2012 - 01:01 PM

I have an MVC 3 application where I've created a .sdf database and am trying to pull information into my .cshtml files.

Here is the code I have so far just to see if I can pull the data:

@using WebMatrix.Data;

@{//title of tab
    ViewBag.Title = "All Metrics";
    var db = Database.Open("Metrics") ;
    var selectCommand = "SELECT * FROM MetricName";
    var searchTerm = "";
}



<div>
    @grid.GetHtml(
        tableStyle: "grid",
        headerStyle: "head",
        alternatingRowStyle: "alt",
        columns: grid.Columns(
            grid.Column(format: @<a href="~/EditMovie?id=@item.ID">Edit</a>),
            grid.Column("Title"),
            grid.Column("Genre"),
            grid.Column("Year"),
            grid.Column(format: @<a href="~/DeleteMovie?id=@item.ID">Delete</a>)
        )
    )
</div>


But get the error:


Compilation Error

Description: An error occurred during the compilation of a resource required to service this request. Please review the following specific error details and modify your source code appropriately.

Compiler Error Message: CS0103: The name 'grid' does not exist in the current context

Source Error:


Line 11:
Line 12: <div>
Line 13: @grid.GetHtml(
Line 14: tableStyle: "grid",
Line 15: headerStyle: "head",

Source File: c:\Users\rflowers\Documents\Visual Studio 2010\Projects\L1DashboardNew\L1DashboardNew\Views\Home\Index.cshtml Line: 13


Show Detailed Compiler Output:

Show Complete Compilation Source:



Any thoughts?

Is This A Good Question/Topic? 0
  • +

Replies To: Compilation error: CS0103: The name 'grid' does not exist in

#2 Nakor  Icon User is offline

  • Professional Lurker
  • member icon

Reputation: 444
  • View blog
  • Posts: 1,492
  • Joined: 28-April 09

Re: Compilation error: CS0103: The name 'grid' does not exist in

Posted 29 August 2012 - 03:23 PM

tutorial You're not initializing the grid.

This post has been edited by Nakor: 29 August 2012 - 03:25 PM

Was This Post Helpful? 1
  • +
  • -

#3 rbflowers  Icon User is offline

  • New D.I.C Head

Reputation: 2
  • View blog
  • Posts: 48
  • Joined: 10-February 12

Re: Compilation error: CS0103: The name 'grid' does not exist in

Posted 30 August 2012 - 09:55 AM

Perfect, thank you.

Is there any way to call specific elements of the database similar to calling an array?

EX) Could I do something like:
<div id="names">
Metric Owner: <myDataBase[0]>
</div>


Thanks
Was This Post Helpful? 0
  • +
  • -

Page 1 of 1