Windows Develop Bookmark and Share   
 index > Windows Forms Data Controls and Databinding > sort a datatable before bind a bindingsource for a datagridview
 

sort a datatable before bind a bindingsource for a datagridview

I have a datatable with some duplications in column "Name", I want to sort the datatable so that the rows of same names are shown together when bind it to a binding source of a datagridview. Is this possilble?

thanks in advance!

Achievement provides the ultimate pleasure in life
ssfftt  13 hours 12 minutes ago

Lets assume dt is your datatable, you can use defaultview's sort property

Here is a sample

dt.DefaultView.Sort = "Column1 ASC,COLUMN2 DESC";
dataGridView1.DataSource = dt.DefaultView;

Tamer Oz  12 hours 52 minutes ago

You can use google to search for other answers

Custom Search

More Threads

• Reading from XML and bound to DatagridView : Adding rows dynamically
• Combobox in a DataGridView
• update TextBox bound to DataView
• Application Settings Cancel Button
• How can I bind a treeview to data returned by a CTE (Common Table Expression) in SQL-2005
• Duplicate Controls & Databinding
• MySQL .NET Connector and DataSet designer issue
• C#/VB.NET Convert double to hexadecimal and vice versa
• DataGridview textbox column is displayed as DataGridView checkbox column
• Getting cell value within datagrid? C++