拍卖是一种类型,在上下文中不是有效的。 [英] Auction is a type,which is not a valid in context .

查看:71
本文介绍了拍卖是一种类型,在上下文中不是有效的。的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

嗨开发者



我正在学习MVC。我正面临一个简单的错误。我试图在ASP.NET MVC中生成webgrid。它显示一个错误



Hi Developers

I am learning MVC. I am facing a simple bug. I am trying to generate webgrid in ASP.NET MVC. It is showing one error

<br />
@model Auctions.Models.Auction<br />
<br />
@{<br />
    ViewBag.Title = "Index";<br />
}<br />
<br />
<h2>Index</h2><br />
<br />
<div><br />
    <h4>Auction</h4><br />
    <hr /><br />
<br />
    @{<br />
        var grid = new WebGrid(Auctions.Models.Auction)---**Error is on this line**<br />
     }<br />
<br />
    @grid.GetHtml(Models.Auction)<br />
    </div><br />
Error: **'Auction' is a type which is not valid in a given context**</pre><br />
<br />
<br />





我的尝试:



。当我尝试将数据加载到mvc 4中的网格时,我得到了这个错误。



What I have tried:

. I am gettting this error when I tried to load a data into a grid in mvc 4.

推荐答案

既然你已经添加了这行,

Since you have already added the line,
@model Auctions.Models.Auction



到你的页面,你必须在创建webgrid时使用如下所示的模型:


to you page, you have to use model like given below when you create your webgrid:

@{
var grid = new WebGrid(source:Model)
}



祝你好运,希望有所帮助。


Good luck and hope that helps.


这篇关于拍卖是一种类型,在上下文中不是有效的。的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆