How to combine two datatables into single datatable - C#
public void getgroupRecentActivity()
{
DataTabledtjoingroup = Group.GetAllGroupDetailbydate(Request.QueryString["GroupID"]);
DataTabledtcreateGroupForum = Group.GetAllGroupForumDetailbydate(Request.QueryString["GroupID"]);
DataSetdsjoin1 = new DataSet();
DataSetdsjoin2 = new DataSet();
foreach(DataRow dr indtjoingroup.Rows)
{
dr["GroupName"] = "commented on the forum";
dr.AcceptChanges();
}
foreach(DataRow dr1 indtcreateGroupForum.Rows)
{
dr1["GroupName"] = "joined the Group";
dr1.AcceptChanges();
}
dsjoin1.Tables.Add(dtjoingroup);
dsjoin2.Tables.Add(dtcreateGroupForum);
dsjoin1.Merge(dsjoin2);
DataTabledtrecentActivity = dsjoin1.Tables[0];
dtrecentActivity.DefaultView.Sort = "date desc";
dtrecentActivity.AcceptChanges();
DataViewdv = new DataView(dtrecentActivity);
dv.Sort = "date desc";
dtRecentActivity = dv.ToTable("dtrecentActivity");
//dtRecentActivity = dtrecentActivity;
dtRecentActivity.AcceptChanges();
//GridView1.DataSource = dtRecentActivity;
//GridView1.DataBind();
//DataView dv = new DataView(dtrecentActivity);
//dv.Sort = "date desc";
//DataTable dtrecentActivityNew = dv.Table;
}
0 comments:
Post a Comment