dataview.sort not working in framework 1.1

A

Archana

Hi all,

I am having table containing 2 columns and 3 rows.

Col1 contains interger valye. I have records with record1 having 2 in
col1, record2 having 5 in col1 and record3 having again 2 in col1.

I am trying to sort this datatable. So what i did is
table.defaultview.sort = 'col1 as'. here i am expecting sorted rows as
2,2,5 which is not happening. But when i bind this datatable to
datagrid on gird sorted table is getting displayed. I am not getting
why table is not sorting but in datagrid showing sorted table.

Please help me in sorting table.

thanks in advance.
 
G

Guest

Archana,

The datatable's defaultview is what get's sorted, which is happening. That
is why it appears sorted in the grid: the grid displays the defaultview.

Kerry Moorman
 
J

James

Hi Archana

Your problem is that a DataTable is never sorted. Only a DataView is
sortable: the rows in the DataTable never move position. Your code is
correct however you will find that it hasn't changed the ordering of
your table, it has changed the ordering of table.DefaultView. When
you bind a DataTable to a DataGrid, the DataGrid actually works with
the table's DefaultView which is why the data is shown in the order
you want.

James
 
A

Archana

Hi,

Thanks for your reply.

Can u tell me then how to sort datatable.? Means from defaultview can
i get sorted datatable?

Because i want table to sorted to do processing.

thanks in advance.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top