本文介绍了从DataSourceControl继承不会产生IDataSource的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试创建自定义数据源控件.

我一直在关注这封信(我认为...).

http://www.nikhilk.net/DataSourceControlBasics.aspx [ ^ ]

我有数据源的基本实现/基本实现,但是当我在标记中声明它并尝试将其静态绑定到gridview时,出现以下错误:

"grdVw"的DataSourceID必须是IDataSource类型的控件的ID


这对我来说似乎很奇怪,因为我的数据源继承自DataSourceControl,后者又实现了IDataSource.即使我在自定义数据源中显式实现IDataSource,也没有任何区别.

我的标记是:

I am trying to create a custom datasource control.

I have been following this article to the letter (I think...).

http://www.nikhilk.net/DataSourceControlBasics.aspx[^]

I have a skeleton / basic implementation of my datasource, however when I declare it in the markup and try to statically bind it to a gridview, I receive the following error:

The DataSourceID of ''grdVw'' must be the ID of a control of type IDataSource


This seems extremely strange to me, since my datasource inherits from DataSourceControl, which in turn implements IDataSource. Even if I explicitly implement IDataSource in my custom datasource, it makes no difference.

My Markup is:

<DataBrokerDataSource  ID="objSrcDBroker" runat="server" />
   
<div>
    <asp:GridView ID="grdVw" DataSourceID="objSrcDBroker" DataMember="Table0" runat="server">
    </asp:GridView>
</div>

<div>
    <asp:GridView id="grdVw2" DataSourceID="objSrcDBroker" DataMember="Table1" runat="server">
    </asp:GridView>
</div>




我的控制权是:




And my control is:

Public Class CustomDataSource
    Inherits DataSourceControl
    Implements IDataSource  'Have tried with this statement included AND excluded = same result

    Protected Overrides Function GetView(ByVal viewName As String) As System.Web.UI.DataSourceView Implements IDataSource.GetView
        'Code here
    End Function

    Protected Overrides Function GetViewNames() As System.Collections.ICollection Implements IDataSource.GetViewNames
        'Code here
    End Function

End Class




我们将不胜感激.




Any help and suggestion will be very much appreciated.

推荐答案


这篇关于从DataSourceControl继承不会产生IDataSource的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

10-14 20:35