【问题标题】:C# Error on Deploy IIS 7: "Both DataSource and DataSourceID are defined on 'GridView1'. Remove one definition."部署 IIS 7 时出现 C# 错误:“DataSource 和 DataSourceID 均在 'GridView1' 上定义。删除一个定义。”
【发布时间】:2014-01-28 12:07:49
【问题描述】:

目标是用 linq 填充网格视图。该代码在 Visual Studio 上运行良好,但在 IIS 7 中部署时出现错误:“DataSource 和 DataSourceID 均在 'GridView1' 上定义。删除一个定义。”

我在服务器端使用属性 DataSource 来填充,而不是使用属性 DataSourceId。

页面aspx的代码:

<asp:GridView ID="GridView1" runat="server">
</asp:GridView>

.cs 中的代码:

protected void Page_Load(object sender, EventArgs e)
        {
            if (!IsPostBack)
            {
                Initialize();
            }
        }

        protected void Initialize()
        {
            LoadGrid();
        }

        protected void LoadGrid()
        {
                dbDataContext dbDataContext = new dbDataContext();


                var entity =
                        from
                            p in dbDataContext.PRODUCTs
                        where
                            p.FL_ACTIVE == true
                        orderby
                            p.DT_CREATION
                        select p;

                GridView1.DataSource = entity;
                GridView1.DataBind();
        }

Adicional 信息:

运行 IIS v7.5 的 Windows 7

运行 .NET Framework 2.0.50727 的应用程序池

项目使用.NET framework 3.5开发

由于配置 IIS 7 而发生错误?

【问题讨论】:

    标签: c# linq iis gridview


    【解决方案1】:

    使用 Id="GridView1" 在整个解决方案中使用 Ct+shif+F 进行搜索,它可能位于其他位置。

    【讨论】:

      猜你喜欢
      • 2012-04-29
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2011-03-25
      • 1970-01-01
      相关资源
      最近更新 更多