"既DataSource和DataSourceID的定义"错误使用ASP.NET的GridView [英] "Both DataSource and DataSourceID are defined" error using ASP.NET GridView

查看:128
本文介绍了"既DataSource和DataSourceID的定义"错误使用ASP.NET的GridView的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

这两个DataSource和DataSourceID的是在grdCommunication定义。删除一个定义。

"Both DataSource and DataSourceID are defined on 'grdCommunication'. Remove one definition."

我今天刚刚得到这个错误,code一直到今天下午我发布的最新版本到我们的服务器,并将其与错误本地和服务器上的突破。我不使用的DataSourceID,应用程序会读取数据库查询到一个DataTable,并将数据表作为在GridView的数据源。我没有在Visual Studio中进行搜索,搜索整个解决方案和字符串的DataSourceID没有出现在整个解决方案甚至1线code的。这是把我吓坏了的第一件事。

I just got this error today, the code has been working until this afternoon I published the latest version to our server and it broke with that error both locally and on the server. I don't use "DataSourceID", the application reads database queries into a datatable and sets the datatable as the DataSource on the GridViews. I did a search in Visual Studio, searching the entire solution and the string "DataSourceID" does not appear in even 1 line of code in the entire solution. This is the first thing that freaked me out.

我想,这已工作昨天,让我恢复了code至昨日的构建。仍然存在的错误。我不停地回去构建,依然这个问题是存在的。我一个月回去了,我仍然得到同样的错误。此应用程序今天上午精细的工作?有真的一直没有code的变化,并在应用程序中没有哪里是对的DataSourceID任何GridView的有史以来设置。有没有人都见过这样的事?

I figure it had been working yesterday, so I reverted the code to yesterday's build. The error was still there. I kept going back a build, and still the issue is there. I went back a month, I am still getting the same error. This application was working fine this morning? There has really been no code changes, and no where in the application is the DataSourceID EVER set on any of the gridviews. Has anyone ever seen anything like this at all??

我怎样才能得到这个错误,如果了DataSourceID从未设置...和单词的DataSourceID是不是在我的解决方案?我只是做了整棵树上做了DataSourceID不区分大小写的搜索中wingrep ....拉升绝对没有。这个词是在整个应用程序绝对没有在那里。

How can I get that error if DataSourceID is never set... and the word "DataSourceID" is not in my solution? I just did a wingrep on the entire tree doing a case insensitive search on datasourceid.... pulled up absolutely nothing. That word is absolutely no where in the entire application.

    <asp:GridView ID="grdCommunication" runat="server" 
    Height="130px" Width="100%"
     AllowPaging="true" >
    ... standard grid view column setup here... 
    </asp:GridView>

// Code behind.. to set the datasource
  DataSet dsActivity = objCompany.GetActivityDetails();

  grdCommunication.DataSource = dsActivity;
  grdCommunication.DataBind();

//更新:去掉了一些令人困惑的笔记。

// Updated: removed some confusing notes.

推荐答案

试试这个:

DataSet dsActivity = objCompany.GetActivityDetails();
grdCommunication.DataSource = dsActivity.Tables[0];
grdCommunication.DataBind();

这篇关于&QUOT;既DataSource和DataSourceID的定义&QUOT;错误使用ASP.NET的GridView的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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