Both DataSource and DataSourceID are defined on 'GridView1'. Remove one definition.

Hi Experts,
I used this article to edit items on gridview

But when I searched for a record so that it fills the drid with search results... I get the error above

How do I fix?
protected void Button1_Click(object sender, EventArgs e)
       using (NorthwindDataContext context = new NorthwindDataContext())
            var customers = from c in context.Customers
                            where (c.CustomerID.StartsWith(TextBox1.Text.Trim()))
                            select c;
                            GridView1.DataSource = customers;

Open in new window

Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

Remove DataSourceID attribute from GridView1 definition.

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
SirReadAlotAuthor Commented:
smashing it works!!!!   I am kinda new to linq can u recommend a good book with example codes in it
Good one is "LINQ in Action"
You also can see some videos at
SirReadAlotAuthor Commented:
I realize this is an old post, but I'm getting this error without the DataSourceID defined in either the control or the code behind.  
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
.NET Programming

From novice to tech pro — start learning today.