Note that there are some explanatory texts on larger screens.

plurals
  1. POSpark View Engine and using viewdata confusion
    text
    copied!<p>I can't seem to get a grasp on how to use the viewdata structure in the spark view engine. I have the following code in my controller:</p> <pre><code> // Retrieve the project list from the database var projects = from p in _context.Repository&lt;project&gt;() orderby p.name ascending select p; return View(projects.ToList&lt;project&gt;()); </code></pre> <p>This code works, as I have unit tests returning the correct projects, and my non-spark view worked perfectly. Now I am trying to switch to Spark View Engine and I'm just confused on the syntax. As a side note, I have verified that spark view engine is working and reading my .spark view.</p> <p>Here is what I am using in my list.spark view:</p> <pre><code>&lt;h2&gt;Available Projects&lt;/h2&gt; &lt;viewdata model="IList[[project]]"/&gt; Count: ${model.count} </code></pre> <p>When rendering this view the following error occurs:</p> <pre><code>.../List.Spark(3,16): error CS0103: The name 'model' does not exist in the current context </code></pre> <p>This is referring to the model.count line. Why doesn't this work? I tried passing the project list to the ViewData["projects"] (and replaced model in the spark code with projects) and I get the same error (take out the model.count for projects.count).</p> <p>This is probably something stupid, but I can't seem to figure this out. </p> <p><b>Update:</b></p> <p>Well I fixed this. It seems that the MVC2 web.config file created by VS 2010 Beta 2 was bad. I used a MVC2 web.config file created by VS 2010 RC and it now works. Thanks!</p>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload