Ask a questionAsk a question
 

QuestionLinq to Object

  • Tuesday, November 03, 2009 6:00 PMRaptor8908 Users MedalsUsers MedalsUsers MedalsUsers MedalsUsers Medals
     Has Code
    Hi,
     I have a small problem. A Customer can have two emails. I want to display the customer as one record in Gridview instead of two.
    So,  I am trying some SQL solutions and Linq solution.

    I did something like:

    var query = from p in result.AsEnumerable()
    	group p by p.GetField<Guid>("CustomerId") into g       
            select new { Customer = g };
    
    my result is a DataTable.
    Now from my query, how can bind this to my GridView?
    I have aspBound field like FirstName in the gridView.
    • Moved byNoam Ben-Ami - MSFTMSFTTuesday, November 03, 2009 11:19 PM (From:ADO.NET Entity Framework and LINQ to Entities)
    •  

All Replies

  • Wednesday, November 04, 2009 1:51 PMtechnocrat_aspire Users MedalsUsers MedalsUsers MedalsUsers MedalsUsers Medals
     
    Hi,

    Depending on how you want to show the records I can think of a couple of options

    1. Convert the second email into another column and show it as one record.


    2. Group the records in the grid view so that two email ids are displayed but only one customer row.

    do let us know how you want to display the records.
  • Thursday, November 05, 2009 1:01 AMRaptor8908 Users MedalsUsers MedalsUsers MedalsUsers MedalsUsers Medals
     
    I want to use the second option.