enter image description here

dtnew1.DefaultView.Sort = "Modified DESC";
DataTable unique = dtnew1.DefaultView.ToTable();

In this code's "unique" table I'm getting all values but post title value is getting repeated. I need a distinct value from post title like:

new test 2014-08-02 2  Test              8/2.2014  
test     2014-08-02 2  test testedby a   7/29/2014

Try this:

DataTable unique =dtnew1.AsEnumerable().GroupBy(row => row["Posttitle"]).Select(group => group.FirstOrDefault());

Add System.Data.Linq reference

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.