HOW TO CREATE DATAGRID COLUMNS FROM MULTIPLE RECORDS USING LINQTOSQL?

Ankita Pandey

Total Post:183

Points:1285
Posted by  Ankita Pandey
 768  View(s)
Ratings:
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.

  1. Sumit Kesarwani

    Post:378

    Points:2694
    Re: How to create datagrid columns from multiple records using LinqtoSql?

    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

Answer

NEWSLETTER

Enter your email address here always to be updated. We promise not to spam!