Reputation: 383
Any idea how I can append popular data on unpopular data
private void Bind()
{
var unpopular = ChannelHelper.GetUnpopular();
var popular = ChannelHelper.GetPopular();
Grid.DataSource = popular + unpopular;
Grid.DataBind();
}
Upvotes: 0
Views: 5078
Reputation: 383
I got solution by below code...
data.InsertRange(0,popularChannel);
And this also works...
grdViewOrders.DataSource = populerChannel.Cast<object>().Union(data.Cast<object>());
Thanks all... :)
Upvotes: 0
Reputation: 4753
If you are using ADO.net objects i.e for example Data Tables , Use the follwing syntax to merge the datas
foreach( datarow dr in dtunpopular.rows.count)
{
dtPopular.Import(dr);
}
So, all the Unpopular records are merged into Poplar data table.
If, you are lists, then you can similarly iterate through the list and each item to a new list
Upvotes: 0
Reputation: 6784
if both results returning the same object, then you can merge it
1- if the datatype was datatable then use Sachin idea
2- if list then use popular.Concat(Unpopular).ToList();
hope it will help you regards
Upvotes: 0
Reputation: 40970
Merge these two data source in a single data source and bind the GridView to the single data source.
If these data source are DataTable or DataSet, you can use DataTable.Merge Method.
Upvotes: 3