Marco
Marco

Reputation: 241

Inner Join in LINQ to SQL Not Working

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

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();

Upvotes: 2

Views: 544

Answers (3)

Amy B
Amy B

Reputation: 110151

DataContext db = new projfuncionarioDataContext(); 

Should be:

projfuncionarioDataContext db = new projfuncionarioDataContext(); 

Upvotes: 7

Jim G.
Jim G.

Reputation: 15373

Does your GridView have the AutoGeneratedColumns property set?

Upvotes: 0

Jim G.
Jim G.

Reputation: 15373

Try:

GridView1.DataSource = query.ToList();

Upvotes: 0

Related Questions