The DataSourceID of ‘gridID’ must be the ID of a control of type IDataSource. A control with ID ‘objectcontainerdatasourceID’ could not be found.

The DataSourceID of ‘gridID’ must be the ID of a control of type IDataSource. A control with ID ‘objectcontainerdatasourceID’ could not be found.

Scenario:

I have One grid which is binded with objectcontainerdatasource. But when i try to run a page it shows me error as shown above.. i can’t figure it out why it working like so…but my colleague had found its solution.. Actually i have kept Grid and Objectconatinerdatasource within a Master page and it is underneath of LetZonePart..which is main problem.. when you run a page then it will hide all other controls which will not going to show on page e.g. ObjectContainerdatasoruce: so my old code which is not working is here:

<asp:Content ID=”Content1″ ContentPlaceHolderID=”LeftZoneParts” runat=”Server”>
<asp:GridView ID=”Mygview” runat=”server” AutoGenerateColumns=”false” Width=”950px” DataSourceID=”Myobjcdatasrc” >
<Columns>
//My Cols
</Columns>
</asp:GridView>
<pp:ObjectContainerDataSource runat=”server” ID=”Myobjcdatasrc” DataObjectTypeName=”Employee” />
<asp:content>

Solution:

Just put your grid and all stuff in ContentPlaceHolder rather than LeftZonePart. That’s it..working one is here…

<asp:Content ID=”Content1″ ContentPlaceHolderID=”ContentPlaceHolder1″ runat=”Server”>
<asp:GridView ID=”Mygview” runat=”server” AutoGenerateColumns=”false” Width=”950px” DataSourceID=”Myobjcdatasrc” >
<Columns>
//My Cols
</Columns>
</asp:GridView>
<pp:ObjectContainerDataSource runat=”server” ID=”Myobjcdatasrc” DataObjectTypeName=”Employee” />
<asp:content>

Happy Coding!!!

5 Comments

  • Hi… I’m also getting same error like you. But your post is not helpful for me. I cannot understand your explanation and your code snippets also seems same except with different id’s for ContentPlaceHolderID . Can you please post detail information about how you resolved issue.

  • I almost never leave comments, but i did some searching and wound up here The DataSourceID of ‘gridID’ must be the ID of a control of type IDataSource.

    A control with ID ‘objectcontainerdatasourceID’ could not
    be found. « A Place for C Sharpers/.Netters. And I
    do have 2 questions for you if it’s allright. Could it be only me or does it look like some of the responses look like they are left by brain dead people? 😛 And, if you are writing at other social sites, I’d like
    to keep up with anything fresh you have to post. Could you make a list of all of all your public pages like your
    Facebook page, twitter feed, or linkedin profile?

    • Thank you for the appreciation, it matters a lot! Nothing like that, It’s always a learning and sharing!

      Keep visiting! Keep reading! Keep sharing!

      Sincerely.
      Kiran Patil

  • Hello! Someone in my Myspace group shared this website with us so I came to give it a look.

    I’m definitely enjoying the information. I’m bookmarking and will be tweeting this to my followers!

    Superb blog and amazing design.

Comments are closed.