LINQ2SQL

  • Thread starter Thread starter Raj
  • Start date Start date
R

Raj

var emprecs = from tab in n.Mapping.GetTables() where tab.TableName ==
listBox1.SelectedItem.ToString() select tab;

How do I assign emprecs as datasource to datagridview?

Thank you

Regards
Raj
 
Raj said:
var emprecs = from tab in n.Mapping.GetTables() where tab.TableName ==
listBox1.SelectedItem.ToString() select tab;

How do I assign emprecs as datasource to datagridview?

Thank you

Regards
Raj

Depends.
I would usually expect that to be taking part in some sort of data access
layer which exposed a list to an objectdatasource.
But the first article I googled with linq asp.net was:
http://msdn.microsoft.com/en-us/library/bb907622.aspx

Maybe you want to try google for yourself.
 
Raj said:
Is there any way? The link talks about datagrid and not datagridview!

From the link.
See where it says "GridView1" - that's a datagridview

protected void Page_Load(object sender, EventArgs e)
{
if (!IsPostBack)
{
AdventureWorksDataContext dataContext =
new AdventureWorksDataContext();

var query = from contact in dataContext.Contacts
where contact.EmailPromotion==1
select contact;

GridView1.DataSource = query;
GridView1.DataBind();
}
}
 
Raj said:
I am writing the application in C# 3.0 which does not have DataBind()
method!

Yes it does.

What I guess you mean is you are writing a windows application rather than
asp.net.
 
Back
Top