【发布时间】:2014-03-13 02:23:49
【问题描述】:
我对 ASP.net 比较陌生,在学习它时,我遇到了人们用来将数据绑定到 GridView 的不同方式:
- SqlDataSource
- 对象数据源
- 从后面的代码中将 DataTable 绑定到 GridView 控件。
首选哪种方式以及在什么情况下?
谢谢
【问题讨论】:
标签: c# asp.net gridview sqldatasource objectdatasource
我对 ASP.net 比较陌生,在学习它时,我遇到了人们用来将数据绑定到 GridView 的不同方式:
首选哪种方式以及在什么情况下?
谢谢
【问题讨论】:
标签: c# asp.net gridview sqldatasource objectdatasource
这取决于要求。但是ObjectDataSource 和Binding DataTable to GridView control from the code behind 比SqlDataSource 更好。当您使用 linq 或 MVC 时,首选 ObjectDataSource,对于多层架构 ASP.NET,首选 Binding DataTable to GridView control from the code behind,
我希望你能得到答案。
【讨论】: