toad
toad

Reputation: 57

How to get date from a dataset in C#?

I have a dataset in which I have three columns. It is a store database in which number of different goods are sold on a particular date. The date can be repeated. For example, for date one item A sold 5 units, item B sold 10, and C sold 15. Here the same date is repeated 3 times. For the next date similar data can be in the dataset. What I want is to get this date one time and make it the header in a datalist and show values of the other two columns in an inner datalist. Likewise I want to do the same for all other dates in that dataset.

Upvotes: 2

Views: 452

Answers (2)

Rafa Castaneda
Rafa Castaneda

Reputation: 832

Supposing you have your data loadede in memory in a typed dataset, you could group it with LINQ:

var query = from salesRow in dataSet
            group salesRow by salesRow.SoldDate;
// Do something with the query like iterate it, databanind it, etc.

Upvotes: 1

V4Vendetta
V4Vendetta

Reputation: 38200

I think it would be better if you can get the list separately from the database. Else you will have to loop through and get the desired list. Select, RowFilter all these function like where clause so getting distinct via that won't be possible

Upvotes: 0

Related Questions