• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 2462
  • Last Modified:

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

0
SirReadAlot
Asked:
SirReadAlot
  • 2
  • 2
1 Solution
 
lazyberezovskyCommented:
Remove DataSourceID attribute from GridView1 definition.
0
 
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

Featured Post

The new generation of project management tools

With monday.com’s project management tool, you can see what everyone on your team is working in a single glance. Its intuitive dashboards are customizable, so you can create systems that work for you.

  • 2
  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now