Error: Both DataSource and DataSourceID are defined on ‘controlname’. Remove one definition.

Assuming you don’t actually have both a DataSource and DataSourceId defined on the same control, this may actually be a bug.  My situation is Visual Studio 2008, compiling an application for .NET 2.0.  I tested this with both Enterprise Library 2.0 and Enterprise Library 3.1.  For me, I’m trying to hydrate a RadioButtonList from a dataset, which is created from a stored procedure call with a parameter passed.  If I hardcode some values in the sproc and don’t pass the parameter, it all works fine.  But, if I pass the parameter, I get the error.  I have a workaround in mind, and I’ll post it whenI get it done.


I reported this at http://connect.microsoft.com/, with an issue ID = 323454; the title is “Both DataSource and DataSourceID are defined…”.  If you’re having the same problem, log in and vote for this issue–more votes = higher priority.  The text of my report is below:



I’m using VS 2008 (9.0.21022.8 RTM), compiling for the .NET 2.0 framework.

On a web form, I’ve added a RadioButtonList, as below:

<asp:RadioButtonList ID=”rblShippingPlatform” runat=”server” CssClass=”FormFieldsAjax” />

In code behind, I call a function in a CBO in the same project to hydrate the values:

cPub.fillShippingPlatforms(rblShippingPlatform, cPublic.Segment.Lane)

The function in the CBO makes a call to the DAL, which is a shared library added as a project reference:

    Public Sub fillShippingPlatforms(ByVal rblPlatforms As RadioButtonList, ByVal sSegment As String)
        With rblPlatforms
            .DataSource = cDb.GetShippingPlatforms(sSegment)
            .DataValueField = “ShippingPlatformID”
            .DataTextField = “ShippingPlatform”
            .DataBind()
        End With
    End Sub

The DAL simply executes a stored procedure and returns a dataset:

    Public Function GetShippingPlatforms(ByVal sSegment As String) As DataSet
        dB = DatabaseFactory.CreateDatabase
        cmd = dB.GetStoredProcCommand(“lpGetShippingPlatforms”)

        With dB
            .AddInParameter(cmd, “@Segment”, DbType.String, sSegment)
            Return .ExecuteDataSet(cmd)
        End With

    End Function

There’s nothing fancy here, but when I load the web form, I receive an error stating “Both DataSource and DataSourceID are defined on ‘rblShippingPlatform’. Remove one definition. “.

I can hydrate the RadioButtonList if I adjust the stored procedure and remove the parameter handling.

    Public Function GetShippingPlatforms(ByVal sSegment As String) As DataSet
        dB = DatabaseFactory.CreateDatabase
        Return dB.ExecuteDataSet(CommandType.StoredProcedure, “lpGetShippingPlatforms”)
    End Function

This issue occurs with both the Jan 2006 and May 2007 versions of the Enterprise Library.

One thought on “Error: Both DataSource and DataSourceID are defined on ‘controlname’. Remove one definition.”

  1. I am just having the same problem with a DDL, only in the runtime version. It was all working before, and I didn’t change anything with the DDL. Surely there is no DataSourceID assigned.

    I am embarrased about Microsoft not solving this problem.

Comments are closed.