Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6096821
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 23, 20262026-05-23T12:58:18+00:00 2026-05-23T12:58:18+00:00

I put this as a datasource in my gridView var source = from p

  • 0

I put this as a datasource in my gridView

var source = from p in allComments
         select new {p.Img, p.Name, p.Comment};
          GridView1.DataSource = source;
          GridView1.DataBind();

and i get this:

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

A control with ID ‘SqlDataSource1’ could not be found.

My Gridview Markup:

     <asp:GridView ID="GridView1" runat="server" AutoGenerateColumns="False"
        style="z-index: 1; left: 317px; top: 374px; position: absolute; height: 597px; width: 666px" 
       BackColor="#CCCCCC" BorderColor="#999999" 
        BorderWidth="0px" CellPadding="4" CellSpacing="2" 
        DataSourceID="SqlDataSource1" ForeColor="Black" AllowPaging="True" 
        onrowdatabound="GridView1_RowDataBound">

 <Columns>
      <asp:TemplateField HeaderText="#">
                        <HeaderStyle Width="500px" />
                         <ItemStyle Width="500px" />
                        <ItemTemplate>
                            <asp:Label ID="lblMessage" runat="server"  Text='<%# Bind("Comment") %>'></asp:Label>
                        </ItemTemplate>
       </asp:TemplateField>

           <asp:TemplateField HeaderText="#">
                        <HeaderStyle Width="100px" />
                          <ItemStyle Width="100px" />
                        <ItemTemplate>
                            <asp:Image ID="imgName" runat="server"  imageUrl='<%# Bind("Img") %>'></asp:Image><br />
                            <asp:Hyperlink ID="hyperLink" runat="server"  Text='<%# Bind("Name") %>' ></asp:Hyperlink>
                        </ItemTemplate>
       </asp:TemplateField>
   </Columns>

      </asp:GridView>
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-23T12:58:19+00:00Added an answer on May 23, 2026 at 12:58 pm

    Remove DataSourceID="SqlDataSource1" from the Gridview, as you set the DataSource in Code behind..

    var source = from p in allComments
    select new {p.Img, p.Name, p.Comment};
    GridView1.DataSource = source;
    GridView1.DataBind();
    

    You can either assign DataSourceID or DataSource, but can’t do both.

    Edit: Following your comments, you have a problem in Paging, to handle paging you have to to bind the data again.

     protected void GridView1_PageIndexChanging(object sender, GridViewPageEventArgs e)
    {
        GridView1.PageIndex = e.NewPageIndex;
        var source = from p in allComments
                     select new { p.Img, p.Name, p.Comment };
        GridView1.DataSource = source;
        GridView1.DataBind();
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

If I put this tag in my HTML: <img src=http://server/imageHandler.php?image=someImage.jpg /> instead of <img
In my Apache webserver I put this: <Directory /var/www/MYDOMAIN.com/htdocs> SetHandler mod_python PythonHandler mod_python.publisher PythonDebug
This is what I have written: if ((lstProperty[i].PropertyIdentifier as string).CompareTo(Name) == 0) Resharper put
i have a gridview table like this... <div> <asp:GridView ID=GridView1 runat=server AllowSorting=true OnSorting=TaskGridView_Sorting >
Is this functionality going to be put into a later Java version? Can someone
I'm about to put my head thru this sliding glass door. I can't figure
I am trying to put some distributed caching into play, I'm using this indeXus.Net
Note: Let me appologize for the length of this question, i had to put
Ok, this is possibly borderline-subjective, but I wonder where one would put a simple
How can I construct my ajaxSend call, this seems like the place to put

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.