P
prichards14
I am working on a project developed by another programmer. Currently,
there is no support for DataGrid sorting. If I set AllowSorting to
True, I can sort by clicking the column headers. However, the sort
order of the data in the underlying DataSet is not altered.
As an example, I have a DataGrid with one column containg data rows B,
C, A. If I click the column header, the data is sorted A, B, C. If I
select the second row and click Edit, the Edit form displays the data
for C, not B.
I have been reading articles and postings for hours on some
workarounds, but I have not found a solution. I want to bind the data
to the grid in such a way that if I sort the grid by clicking a column
header, the underlying data is sorted as well.
One post I read said that using a DataSet with a DataGrid creates a
default DataView that is not bound to the grid, as far as sorting is
concerned. The poster said to explicitly create a DataView for the
DataSet and bind it to the DataGrid. This is what I want to do, but I
have no idea how.
A simple code example would help me the most, or a link to web site
that explains this. I am very new to .Net and I am really struggling
with this.
Thanks!
-Pat
there is no support for DataGrid sorting. If I set AllowSorting to
True, I can sort by clicking the column headers. However, the sort
order of the data in the underlying DataSet is not altered.
As an example, I have a DataGrid with one column containg data rows B,
C, A. If I click the column header, the data is sorted A, B, C. If I
select the second row and click Edit, the Edit form displays the data
for C, not B.
I have been reading articles and postings for hours on some
workarounds, but I have not found a solution. I want to bind the data
to the grid in such a way that if I sort the grid by clicking a column
header, the underlying data is sorted as well.
One post I read said that using a DataSet with a DataGrid creates a
default DataView that is not bound to the grid, as far as sorting is
concerned. The poster said to explicitly create a DataView for the
DataSet and bind it to the DataGrid. This is what I want to do, but I
have no idea how.
A simple code example would help me the most, or a link to web site
that explains this. I am very new to .Net and I am really struggling
with this.
Thanks!
-Pat