I use WebMatrix, I created a database and placed a table with several rows of data. I can connect to it and get data using WebGrid , but it only provides a way to output data using a table.
Here is my code for 'shows.cshtml':
@{ var db = Database.Open("TVPort"); var shows_data = db.Query("SELECT * FROM shows"); var shows_grid = new WebGrid(source: shows_data); }
What I would like to do is to list each row returned by the query and do whatever I want with the value of each column. But WebGrid allows you to output data to a table. I just started using WebMatrix and Razor syntax today.
Also (side question here, didn't think it was enough to be his own question), is there a way to make a C # code file for my show.cshtml page? In Visual Web Developer 2010, each page has a page.aspx and a page.aspx.cs file, where the page.aspx.cs file allows you to create custom functions on the page or perform a task when the page loads. Is there any similar behavior using CSHTML in WebMatrix? Or should all the code be embedded with the actual page?
source share