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

Hi Experts,
I used this article to edit items on gridview
http://mohamedatiasblog.wordpress.com/

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?
thanks
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;
                            GridView1.DataBind();
        }
    }

Open in new window

SirReadAlotAsked:
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.

lazyberezovskyCommented:
Remove DataSourceID attribute from GridView1 definition.
0

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
0
lazyberezovskyCommented:
Good one is "LINQ in Action"
You also can see some videos at www.asp.net/learn/linq-videos/
0
SirReadAlotAuthor Commented:
THANKS
0
Airstream345Commented:
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.  
0
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.