Click here to Skip to main content
15,920,708 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
C#
i have two datatables,

DataTable dt1=obj.SomeFunction();
DataTable dt2=obj.SomeFunction();

// I put an iteration on dt1 to select some value from dt2 e.x

foreach(DataRow row in dt1.Rows)

{
string s=dt1.row["ColumnName"].ToString();

var newquery = from b in dt2.AsEnumerable()
               let somevariable= b.Field<string>("DataColumn").ToString()
                      where (s== somevariable)

                      select new
                      {
                          somevariable

                      };
//here i want to add each itteration into list<> and then. add the list<> to dt1
}
Posted
Updated 28-May-14 20:04pm
v3

1 solution

Try
C#
dt1.Merge(dt2.AsEnumerable().Where(x=>x.Field<string>("DataColumn") == somevariable).CopyToDataTable());
 
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