简体   繁体   English

为什么ASP.NET MVC 2和3在工具箱中具有gridview?

[英]Why does ASP.NET MVC 2 and 3 have gridview in toolbox?

Its pretty simple to create a gridview like object with a strongly-typed view; 创建带有强类型视图的类似于gridview的对象非常简单; it pretty much does it for you. 它为您做了很多。 I can also use a foreach and create the HTML dynamically. 我还可以使用foreach并动态创建HTML。 Same diff. 相同的差异 (The process of getting that data from the controller to the view is still magical to me). (对我来说,从控制器到视图获取数据的过程仍然很神奇)。

AFAIK, MVC doesn't support viewstate. AFAIK,MVC不支持viewstate。 MVC doesn't have a way to reference and set GridView1.Datasource = SomeDataSource; MVC无法引用和设置GridView1.Datasource = SomeDataSource; in the Controller either. 在控制器中。

So why is Gridview available in the toolbox when I can't set the datasource? 那么,当我无法设置数据源时,为什么在工具箱中可以使用Gridview? Is the gridview useable? gridview是否可用? Is anything in the toolbox useable (outside standard HTML)? 工具箱中的任何东西都可用(标准HTML之外)?

因为如果使用WebForms视图,Visual Studio会检测到.aspx / .ascx文件。

Generally speaking nothing in the toolbox is usable for ASP.NET MVC. 通常,工具箱中的任何内容都无法用于ASP.NET MVC。 At least not usable in the sense that it was in ASP.NET Classic. 至少在ASP.NET Classic中不可用。 This is just a remnant of the fact that ASP.NET MVC is built on top of ASP.NET Classic and Visual Studio's designers were created before MVC existed. 这只是ASP.NET MVC建立在ASP.NET Classic之上并且Visual Studio的设计者是在MVC出现之前创建的事实的残余。

The book "ASP.NET MVC in Action" has a chapter that talks about using classic ASP.NET controls in MVC. 《行动中的ASP.NET MVC》一书讨论了在MVC中使用经典ASP.NET控件的一章。 The general take away from that chapter (at least in my opinion) is don't bother. 总的来说,不要再费心(至少在我看来)。 The ones that are still usable are neutered and don't really provide any real benefit. 仍然可用的那些已经绝育了,并没有真正提供任何真正的好处。 MVC just wasn't designed with ASP.NET controls in mind (which IMO, is a great thing). MVC并不是在设计时就考虑到ASP.NET控件(这对IMO来说是一件好事)。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM