Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 4024138
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 20, 20262026-05-20T10:41:04+00:00 2026-05-20T10:41:04+00:00

I have a DataGridView which is bound to a DataTable that contains a column

  • 0

I have a DataGridView which is bound to a DataTable that contains a column of custom types that I need to sort by. This custom type (MyCustomType) implements IComparable<MyCustomType> which is how I wanted the sorting to work.

I tried 2 methods to create a DataView which I would use as the grid’s data source:

MyDataTable dt = new MyDataTable();
DataView dv = new DataView(dt);
dv.Sort = "MyCustomField";

This did not really work properly – it “almost” worked, but sometimes my rows would not be sorted correctly.

Second method:

MyDataTable dt = new MyDataTable();
DataView dv = dt.OrderBy(row => row.MyCustomField).AsDataView();

This seems to be doing what I want. My question is, what’s the difference between these two methods? Is it possible that DataView.Sort is not using my IComparable<T> implementation, and the LINQ-enabled DataView is? Why would that be the case?

Furthermore, does anyone know about the relative performance of non-LINQ-enabled and LINQ-enabled DataViews? It seems like if there isn’t a huge performance hit, there’s no longer any reason to use the non-LINQ-enabled version.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-20T10:41:05+00:00Added an answer on May 20, 2026 at 10:41 am

    When you call .Sort on the DataView, it sorts this particular instance of the object. Your second method actually creates a brand new object and assigns to the dv variable. This can be a critical difference.

    EDIT: Not your second method specifically, since you’re not assigning, then re-assigning. But if you had an existing DataView, then re-assigned it using the OrderBy method, then you’d have the scenario I suggested.

    Sorry, I wasn’t as clear as I should have been.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a DataGridView bound to a DataTable that has 1+16 columns defined as
I have a DataTable which is bound to datagridview (Winforms)... I use the following
I have a datagridview which is initially bound to an empty datatable. Then the
I have a datagridview which im binding DataTable to. What I want do is
Say I have a DataGridView in which I dynamically build up a ComboBox column
This is a C# Winform question. I have a DataGridView which is bounded to
If you have a DataGridView that is bound to a DataView (someDataTable.DefaultView). ..and a
I Have a Datagridview bound to a datatable wich hold data from a database
Hi I have a datagridview which binds XML manually. I wish to sort out
Hi I have a DataGridView which is bound to an XML source. I have

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.