views:

68

answers:

3

What's wrong with my code? For the Employee table and the table Project are underlined in red ...

Thanks in advance!

 DataContext db = new projfuncionarioDataContext();


        var query = from p in db.Funcionario
                    join c in db.Projeto on p.Cdfunc equals c.Cdfunc
                    select new
                    {
                        ID = p.Cdfunc,
                        Produto = p.Nome,
                    };

        GridView1.DataSource = query;
        GridView1.DataBind();
A: 

Try:

GridView1.DataSource = query.ToList();
Jim G.
I tried it but this did not work...
Marco Antônio
A: 

Does your GridView have the AutoGeneratedColumns property set?

Jim G.
+6  A: 
DataContext db = new projfuncionarioDataContext(); 

Should be:

projfuncionarioDataContext db = new projfuncionarioDataContext(); 
David B
+1 Wow... I can't believe I and everyone else didn't notice this for such a long time!
Mark Byers
Kudos to you for posting a code sample and error message.
David B