I have this in my webpage
@{
if(!IsPost){
var db = Database.Open("MyDatabase");
var catList= db.Query("select * from category");
}
else{
var db = Database.Open("MyDatabase");
var query = "insert into product (productkey,productname,categorykey) values(@0,@1,@2)";
....more code....
}
}
In my html I have the following
<select id="categorySelect" name="Name">
@foreach(var cat in catList){
<option value=cat.CategoryKey>@cat.CategoryName</option>
}
</select>
Problem is that when navigating to this page the first time I get this CS0103 exception saying that The name catList
does not exist in the context
I am loading this page from a link in another page. What is wrong in my code?