Click here to Skip to main content
15,885,954 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
hi friends,
here with i have post my code for your reference.
C#
DataTable dtConfig = TesterSlotTypeGroupDAL.GetConfiguredTSTGroupRows();
           DataTable dt = new DataTable("dTable");
           DataRow dr; int iColCtr = 2;
           var vGroups = from c in dtConfig.AsEnumerable()
                         select new
                         {
                             TST_GroupId = c.Field<decimal>("id"),
                             TST_Group = c.Field<string>("TST Group")
                         };
           foreach (var vGroup in vGroups.Distinct())
           {
               if (dt.Rows.Count == 0)
               {
                   dt.Columns.Add("id");
                   dt.Columns.Add("TST Group");
                   dt.Columns.Add("Machine Size Slot");

                   dt.Columns.Add("Slot");
               }
               dr = dt.NewRow();
               dr[0] = vGroup.TST_GroupId.ToString();
               dr[1] = vGroup.TST_Group.ToString();

               dt.Rows.Add(dr);
           }

           dgv.DataSource = dt;

note:
foreach (var vGroup in vGroups.Distinct()) in this line i am getting error. can you pls give me a idea how to resolve this issue..,

Regards
Siva
Posted
Updated 9-Jul-12 19:51pm
v2

1 solution

Try vGroups.AsEnumerable().Distinct()
 
Share this answer
 
v3

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900