Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations TouchToneTommy on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

DataGrid Sort

Status
Not open for further replies.

Ladyhawk

Programmer
Jan 22, 2002
534
AU
Is there any way to programmatically sort a column in a datagrid?

Ladyhawk. [idea]
** ASP/VB/Java Programmer **
 
If you bind the datagrid to a dataview you can sort the dataview. Might be an option if you cant find any other way.
 
Ladyhawk,

are you trying to sort a windows datagrid in some special way more specific than the click to sort thingy?

bassguy

 
I wanted to programmatically initiate the "click to sort thingy".

Ladyhawk. [idea]
** ASP/VB/Java Programmer **
 
Ladyhawk...I am still confused a bit. are you saying that some event would do the sort or are you saying that the page would load then sort automatically?

bassguy
 
Yes it is possible
try this:
-let's say that ds.tables(0) is yours grid dataSource
-the name of the column you want to sort is "Column"
ds.Tables(o).DefaultView.sort= "Column"
grid1.DataSource = ds.Tables(0).DefaultView
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top