Home > DeveloperSection > Forums > How to create datagrid columns from multiple records using LinqtoSql?
Ankita Pandey
Ankita Pandey

Total Post:183

Points:1285
Posted on    August-25-2014 1:27 AM

 ASP.Net ASP.Net 
Ratings:


 1 Reply(s)
 590  View(s)
Rate this:

I have a sql table and I want each record to be a datagrid column and another sql table with multiple records related to each fieldID.

I would like to display each value in the appropiate column of a datagrid using linq.



Sumit Kesarwani

Total Post:378

Points:2694
Posted on    August-25-2014 2:24 AM

Hi Ankita, 

var dc = new YourdataContext();

    yourGrid.DataSource = dc.YourTable.Select( t => new { 

                                                    t.Property1,

                                                    t.RelationTable.Property2,

                                                    etc...                    

                                                  } );

   yourGrid.DataBind();

and add this in the page_load or page_init


Don't want to miss updates? Please click the below button!

Follow MindStick