Quantcast
Channel: DataSource Controls - SqlDataSource, ObjectDataSource, etc.
Viewing all articles
Browse latest Browse all 956

How to Show data from 10 tables in a single grid view according to date time descending sort

$
0
0
  • I Have 10 tables in total and containing same column in each table,
  • Now i want to show the data from all the 10 tables at once in a single grid view according to date time descending sort. And I want to execute the above query use data set.
  • I still found out a way to fix this using data view and data table. But this trick fails in sorting bulk data.
  • Is there any other alternative to fix this?

here is my code..

ds2.Clear();
SqlDataAdapter getnewsfeeds;
SqlDataAdapter friendadapter = new SqlDataAdapter("select * from " + Session["username"].ToString() + "_friends ", friendscon);
friendadapter.Fill(friendsdataset);
int friendrowcount = friendsdataset.Tables[0].Rows.Count;
if (friendrowcount > 0)
{

    for (int i = 0; i < friendrowcount; i++)
    {
        friendstringtable = " " + friendsdataset.Tables[0].Rows[i]["friendsusername"].ToString();
        getnewsfeeds = new SqlDataAdapter("select top 5 * from " + friendstringtable + "_newsfeeds order by id desc", Newsfeedscon);
        getnewsfeeds.Fill(ds2, "newsfeed");
    }

}
getnewsfeeds.Fill(ds2, "newsfeed");
ds2.Tables["newsfeed"].DefaultView.Sort = "time_date desc";
DataView dv = ds2.Tables["newsfeed"].DefaultView;
dt = dv.ToTable();


Viewing all articles
Browse latest Browse all 956

Latest Images

Trending Articles



Latest Images

<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>