【问题标题】:When using GridView, which is the best option to bind it to the datasource?使用 GridView 时,将其绑定到数据源的最佳选择是什么?
【发布时间】:2014-03-13 02:23:49
【问题描述】:

我对 ASP.net 比较陌生,在学习它时,我遇到了人们用来将数据绑定到 GridView 的不同方式:

  1. SqlDataSource
  2. 对象数据源
  3. 从后面的代码中将 DataTable 绑定到 GridView 控件。

首选哪种方式以及在什么情况下?

谢谢

【问题讨论】:

    标签: c# asp.net gridview sqldatasource objectdatasource


    【解决方案1】:

    这取决于要求。但是ObjectDataSourceBinding DataTable to GridView control from the code behindSqlDataSource 更好。当您使用 linq 或 MVC 时,首选 ObjectDataSource,对于多层架构 ASP.NET,首选 Binding DataTable to GridView control from the code behind, 我希望你能得到答案。

    【讨论】:

    • 谢谢。这就是我决定做的事
    猜你喜欢
    • 2023-03-06
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2011-06-25
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多