Skip to content
April 22, 2008 / kiranpatils

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

Leave a Comment
  1. ranjithkumar / Jan 3 2012 12:38 pm

    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.

  2. Burkhardt and Larson / Apr 26 2013 8:03 pm

    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? :-P 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?

    • kiranpatils / May 1 2013 6:15 pm

      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

  3. Order Trimextrin / May 5 2013 11:38 pm

    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.

  4. put cccam prio / May 20 2013 12:15 pm

    Hello, I check your blogs like every week. Your humoristic
    style is awesome, keep up the good work!

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

Follow

Get every new post delivered to your Inbox.

Join 505 other followers

%d bloggers like this: