473,396 Members | 1,774 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,396 software developers and data experts.

dataview sorting problem -

Hi
I'm creating a dataview "on the fly" in order to sort some data prior to writing out the information to a MS SQL table
I have used two methods in order to determine the sort order of the DataView. (I'm writing in C# with the v1.1.4322 of the .NET Framework, in Window2K server"). First of all, here are the two methods I have used in order to apply the sorting property to the DataView

1. Simply defining the sort order and colum
DataView dvReturn

string szSort = "DataRowID" + " ASC"
vReturn.Sort = szSort

2. Defining a primary key and then setting the default sort order
propert
/// when creating the datatable firs
DataTable dt
dt.PrimaryKey = new DataColumn[] {dt.Columns["DataRowID"]}
DataView dvFinal = new DataView(dt)

// then set the propert
dvFinal.ApplyDefaultSort = true

When I attempt to access the data from the DataView, the information is still listed as if it hasn't been sorted. Here is a sample of the code I have implemented in order to retrieve the sorted information (dvReturn would be the DataView I applied the sorting properties to

int iRowID = System.Convert.ToInt32(dvReturn[j]["DataRowID"].ToString())
int iEmpStatusID = System.Convert.ToInt32(dvReturn[j]["EmpStatusTypeID"].ToString())

Any help would be greatly appreciated, as it is not obvious to me what I am doing wrong. Thank you in advance

jwede

Jul 21 '05 #1
9 2537
Jwedel:

If you call ApplyDefaultSort after the sort, it will undo the sort you
specified and use the original one. What exactly is that last reference
doing? It looks like you are just referencing one row, so whatever J is
will determine the sort order. Nonetheless, if you just use Sort like you
did in the first one, regardless of primary key, you'll sort on that field.
"jwedel_stolo" <an*******@discussions.microsoft.com> wrote in message
news:F0**********************************@microsof t.com...
Hi,
I'm creating a dataview "on the fly" in order to sort some data prior to writing out the information to a MS SQL table. I have used two methods in order to determine the sort order of the DataView. (I'm writing in C# with the v1.1.4322 of the .NET Framework, in
Window2K server"). First of all, here are the two methods I have used in
order to apply the sorting property to the DataView.
1. Simply defining the sort order and column
DataView dvReturn;

string szSort = "DataRowID" + " ASC";
vReturn.Sort = szSort;

2. Defining a primary key and then setting the default sort order property
/// when creating the datatable first
DataTable dt;
dt.PrimaryKey = new DataColumn[] {dt.Columns["DataRowID"]}; DataView dvFinal = new DataView(dt);

// then set the property
dvFinal.ApplyDefaultSort = true;

When I attempt to access the data from the DataView, the information is still listed as if it hasn't been sorted. Here is a sample of the code I
have implemented in order to retrieve the sorted information (dvReturn would
be the DataView I applied the sorting properties to)
int iRowID = System.Convert.ToInt32(dvReturn[j]["DataRowID"].ToString());
int iEmpStatusID = System.Convert.ToInt32(dvReturn[j]["EmpStatusTypeID"].ToString());
Any help would be greatly appreciated, as it is not obvious to me what I am doing wrong. Thank you in advance.
jwedel


Jul 21 '05 #2
Jwedel:

If you call ApplyDefaultSort after the sort, it will undo the sort you
specified and use the original one. What exactly is that last reference
doing? It looks like you are just referencing one row, so whatever J is
will determine the sort order. Nonetheless, if you just use Sort like you
did in the first one, regardless of primary key, you'll sort on that field.
"jwedel_stolo" <an*******@discussions.microsoft.com> wrote in message
news:F0**********************************@microsof t.com...
Hi,
I'm creating a dataview "on the fly" in order to sort some data prior to writing out the information to a MS SQL table. I have used two methods in order to determine the sort order of the DataView. (I'm writing in C# with the v1.1.4322 of the .NET Framework, in
Window2K server"). First of all, here are the two methods I have used in
order to apply the sorting property to the DataView.
1. Simply defining the sort order and column
DataView dvReturn;

string szSort = "DataRowID" + " ASC";
vReturn.Sort = szSort;

2. Defining a primary key and then setting the default sort order property
/// when creating the datatable first
DataTable dt;
dt.PrimaryKey = new DataColumn[] {dt.Columns["DataRowID"]}; DataView dvFinal = new DataView(dt);

// then set the property
dvFinal.ApplyDefaultSort = true;

When I attempt to access the data from the DataView, the information is still listed as if it hasn't been sorted. Here is a sample of the code I
have implemented in order to retrieve the sorted information (dvReturn would
be the DataView I applied the sorting properties to)
int iRowID = System.Convert.ToInt32(dvReturn[j]["DataRowID"].ToString());
int iEmpStatusID = System.Convert.ToInt32(dvReturn[j]["EmpStatusTypeID"].ToString());
Any help would be greatly appreciated, as it is not obvious to me what I am doing wrong. Thank you in advance.
jwedel


Jul 21 '05 #3
William
1. Apologies for the ambiguity.... I have not used the two sorting mechanisms concurrently. I am aware if you set the sort order initially (as in item #1) and then set the "ApplyDefaultSort" property to "true", that it will overwrite the inital sort ou specificed.... (it is clearly stated in the documentation)... but thank you anyway

2. The last reference (int iRowID = System.Convert.ToInt32(dvReturn[j]["DataRowID"].ToString()) is referencing a single row, where "j" is simply an iterator within a "for" loop. I am copying the contents of each row within the DataView back to an ArrayList.

I am interested in your comment re: "j" though... how will "j" determine my sort order... ?? Please respond at your convenience, and thank you for the assistance

Regards
jwede
----- William Ryan eMVP wrote: ----

Jwedel

If you call ApplyDefaultSort after the sort, it will undo the sort yo
specified and use the original one. What exactly is that last referenc
doing? It looks like you are just referencing one row, so whatever J i
will determine the sort order. Nonetheless, if you just use Sort like yo
did in the first one, regardless of primary key, you'll sort on that field
"jwedel_stolo" <an*******@discussions.microsoft.com> wrote in messag
news:F0**********************************@microsof t.com..
Hi
I'm creating a dataview "on the fly" in order to sort some data prio to writing out the information to a MS SQL table I have used two methods in order to determine the sort order of th DataView. (I'm writing in C# with the v1.1.4322 of the .NET Framework, i
Window2K server"). First of all, here are the two methods I have used i
order to apply the sorting property to the DataView
1. Simply defining the sort order and colum

DataView dvReturn
string szSort = "DataRowID" + " ASC"

vReturn.Sort = szSort
2. Defining a primary key and then settin the default sort orde propert
/// when creating the datatable firs
DataTable dt
dt.PrimaryKey = new DataColumn[ {dt.Columns["DataRowID"]} DataView dvFinal = new DataView(dt)
// then set the propert

dvFinal.ApplyDefaultSort = true
When I attempt to access the data from the DataView, the informatio

is still listed as if it hasn't been sorted. Here is a sample of the code
have implemented in order to retrieve the sorted information (dvReturn woul
be the DataView I applied the sorting properties to int iRowID = System.Convert.ToInt32(dvReturn[j]["DataRowID"].ToString())

int iEmpStatusID

System.Convert.ToInt32(dvReturn[j]["EmpStatusTypeID"].ToString())
Any help would be greatly appreciated, as it is not obvious to me wha I am doing wrong. Thank you in advance jwede
>

Jul 21 '05 #4
William
1. Apologies for the ambiguity.... I have not used the two sorting mechanisms concurrently. I am aware if you set the sort order initially (as in item #1) and then set the "ApplyDefaultSort" property to "true", that it will overwrite the inital sort ou specificed.... (it is clearly stated in the documentation)... but thank you anyway

2. The last reference (int iRowID = System.Convert.ToInt32(dvReturn[j]["DataRowID"].ToString()) is referencing a single row, where "j" is simply an iterator within a "for" loop. I am copying the contents of each row within the DataView back to an ArrayList.

I am interested in your comment re: "j" though... how will "j" determine my sort order... ?? Please respond at your convenience, and thank you for the assistance

Regards
jwede
----- William Ryan eMVP wrote: ----

Jwedel

If you call ApplyDefaultSort after the sort, it will undo the sort yo
specified and use the original one. What exactly is that last referenc
doing? It looks like you are just referencing one row, so whatever J i
will determine the sort order. Nonetheless, if you just use Sort like yo
did in the first one, regardless of primary key, you'll sort on that field
"jwedel_stolo" <an*******@discussions.microsoft.com> wrote in messag
news:F0**********************************@microsof t.com..
Hi
I'm creating a dataview "on the fly" in order to sort some data prio to writing out the information to a MS SQL table I have used two methods in order to determine the sort order of th DataView. (I'm writing in C# with the v1.1.4322 of the .NET Framework, i
Window2K server"). First of all, here are the two methods I have used i
order to apply the sorting property to the DataView
1. Simply defining the sort order and colum

DataView dvReturn
string szSort = "DataRowID" + " ASC"

vReturn.Sort = szSort
2. Defining a primary key and then settin the default sort orde propert
/// when creating the datatable firs
DataTable dt
dt.PrimaryKey = new DataColumn[ {dt.Columns["DataRowID"]} DataView dvFinal = new DataView(dt)
// then set the propert

dvFinal.ApplyDefaultSort = true
When I attempt to access the data from the DataView, the informatio

is still listed as if it hasn't been sorted. Here is a sample of the code
have implemented in order to retrieve the sorted information (dvReturn woul
be the DataView I applied the sorting properties to int iRowID = System.Convert.ToInt32(dvReturn[j]["DataRowID"].ToString())

int iEmpStatusID

System.Convert.ToInt32(dvReturn[j]["EmpStatusTypeID"].ToString())
Any help would be greatly appreciated, as it is not obvious to me wha I am doing wrong. Thank you in advance jwede
>

Jul 21 '05 #5


"jwedel_stolo" <an*******@discussions.microsoft.com> wrote in message
news:09**********************************@microsof t.com...
William,
1. Apologies for the ambiguity.... I have not used the two sorting mechanisms concurrently. I am aware if you set the sort order initially (as
in item #1) and then set the "ApplyDefaultSort" property to "true", that it
will overwrite the inital sort ou specificed.... (it is clearly stated in
the documentation)... but thank you anyway.

I'm lost then, how does it fit in here or is just extraneous code? When
does it get applied b/c the timing of the events with this could easily
explain the problem.
2. The last reference (int iRowID = System.Convert.ToInt32(dvReturn[j]["DataRowID"].ToString()) is referencing a
single row, where "j" is simply an iterator within a "for" loop. I am
copying the contents of each row within the DataView back to an ArrayList..

We need to determine where exactly the problem is. So go ahead and grab the
last value of the datatable in Column0 for instance and see what it is.
Then apply the sort and reference that row within the View! Only the view
is sorted not the datatable. An easy way to do this is make a test grid and
bind to it. Have a button that changes the sort field. Click on it a few
times and make sure it's sorting correctly. You'll have a visual cue if you
use a grid. I've never seen this not work and I use it constantly so I
suspect it may appear that it's not sorting but it's probably the reference
to the row.

I am interested in your comment re: "j" though... how will "j" determine my sort order... ?? Please respond at your convenience, and thank
you for the assistance.

Whatever j will pass that row regardless of how it's sorted. Basically, if
J is 200 and there are 200 rows, you'll get the last row, but after a sort,
if the same row is now position 15, it's only going to be 'correct' when j
is 15.
Regards,
jwedel

----- William Ryan eMVP wrote: -----

Jwedel:

If you call ApplyDefaultSort after the sort, it will undo the sort you specified and use the original one. What exactly is that last reference doing? It looks like you are just referencing one row, so whatever J is will determine the sort order. Nonetheless, if you just use Sort like you did in the first one, regardless of primary key, you'll sort on that field. "jwedel_stolo" <an*******@discussions.microsoft.com> wrote in message
news:F0**********************************@microsof t.com...
> Hi,
> I'm creating a dataview "on the fly" in order to sort some data prior
to writing out the information to a MS SQL table.
> I have used two methods in order to determine the sort order of the DataView. (I'm writing in C# with the v1.1.4322 of the .NET

Framework, in Window2K server"). First of all, here are the two methods I have used in order to apply the sorting property to the DataView. >> 1. Simply defining the sort order
and column
> DataView dvReturn;
>> string szSort = "DataRowID" + " ASC"; > vReturn.Sort = szSort;
>> 2. Defining a primary key and then
setting the default sort order
> property
> /// when creating the datatable
first > DataTable dt;
> dt.PrimaryKey = new DataColumn[]

{dt.Columns["DataRowID"]};
> DataView dvFinal = new DataView(dt);
>> // then set the property

> dvFinal.ApplyDefaultSort = true;
>> When I attempt to access the data from the DataView, the
information is still listed as if it hasn't been sorted. Here is a sample of the code I have implemented in order to retrieve the sorted information (dvReturn would be the DataView I applied the sorting properties to) >> int iRowID =
System.Convert.ToInt32(dvReturn[j]["DataRowID"].ToString()); > int iEmpStatusID = System.Convert.ToInt32(dvReturn[j]["EmpStatusTypeID"].ToString()); >> Any help would be greatly appreciated, as it is not obvious to
me what I am doing wrong. Thank you in advance. >> jwedel
>>>>>

Jul 21 '05 #6


"jwedel_stolo" <an*******@discussions.microsoft.com> wrote in message
news:09**********************************@microsof t.com...
William,
1. Apologies for the ambiguity.... I have not used the two sorting mechanisms concurrently. I am aware if you set the sort order initially (as
in item #1) and then set the "ApplyDefaultSort" property to "true", that it
will overwrite the inital sort ou specificed.... (it is clearly stated in
the documentation)... but thank you anyway.

I'm lost then, how does it fit in here or is just extraneous code? When
does it get applied b/c the timing of the events with this could easily
explain the problem.
2. The last reference (int iRowID = System.Convert.ToInt32(dvReturn[j]["DataRowID"].ToString()) is referencing a
single row, where "j" is simply an iterator within a "for" loop. I am
copying the contents of each row within the DataView back to an ArrayList..

We need to determine where exactly the problem is. So go ahead and grab the
last value of the datatable in Column0 for instance and see what it is.
Then apply the sort and reference that row within the View! Only the view
is sorted not the datatable. An easy way to do this is make a test grid and
bind to it. Have a button that changes the sort field. Click on it a few
times and make sure it's sorting correctly. You'll have a visual cue if you
use a grid. I've never seen this not work and I use it constantly so I
suspect it may appear that it's not sorting but it's probably the reference
to the row.

I am interested in your comment re: "j" though... how will "j" determine my sort order... ?? Please respond at your convenience, and thank
you for the assistance.

Whatever j will pass that row regardless of how it's sorted. Basically, if
J is 200 and there are 200 rows, you'll get the last row, but after a sort,
if the same row is now position 15, it's only going to be 'correct' when j
is 15.
Regards,
jwedel

----- William Ryan eMVP wrote: -----

Jwedel:

If you call ApplyDefaultSort after the sort, it will undo the sort you specified and use the original one. What exactly is that last reference doing? It looks like you are just referencing one row, so whatever J is will determine the sort order. Nonetheless, if you just use Sort like you did in the first one, regardless of primary key, you'll sort on that field. "jwedel_stolo" <an*******@discussions.microsoft.com> wrote in message
news:F0**********************************@microsof t.com...
> Hi,
> I'm creating a dataview "on the fly" in order to sort some data prior
to writing out the information to a MS SQL table.
> I have used two methods in order to determine the sort order of the DataView. (I'm writing in C# with the v1.1.4322 of the .NET

Framework, in Window2K server"). First of all, here are the two methods I have used in order to apply the sorting property to the DataView. >> 1. Simply defining the sort order
and column
> DataView dvReturn;
>> string szSort = "DataRowID" + " ASC"; > vReturn.Sort = szSort;
>> 2. Defining a primary key and then
setting the default sort order
> property
> /// when creating the datatable
first > DataTable dt;
> dt.PrimaryKey = new DataColumn[]

{dt.Columns["DataRowID"]};
> DataView dvFinal = new DataView(dt);
>> // then set the property

> dvFinal.ApplyDefaultSort = true;
>> When I attempt to access the data from the DataView, the
information is still listed as if it hasn't been sorted. Here is a sample of the code I have implemented in order to retrieve the sorted information (dvReturn would be the DataView I applied the sorting properties to) >> int iRowID =
System.Convert.ToInt32(dvReturn[j]["DataRowID"].ToString()); > int iEmpStatusID = System.Convert.ToInt32(dvReturn[j]["EmpStatusTypeID"].ToString()); >> Any help would be greatly appreciated, as it is not obvious to
me what I am doing wrong. Thank you in advance. >> jwedel
>>>>>

Jul 21 '05 #7
Willia
Thanks for all your help. As it turns out, the implementation of the sort and the subsequent accessing of the data is correct. I'm sorting on an integer value. Therefore, if I had an array of integers such as 1,2,13,3... the subsequent sort order will be: 1,13,2,3... I had to preceed the values with a '0' in order to obtain the correct sort order I desired....
(ie; 01, 02, 03, 13... is the sort order I requried).... apologies for wasting your time

regards
jwede

...
Thanks in advance

----- William Ryan eMVP wrote: ----

"jwedel_stolo" <an*******@discussions.microsoft.com> wrote in messag
news:09**********************************@microsof t.com..
William
1. Apologies for the ambiguity.... I have not used the two sortin mechanisms concurrently. I am aware if you set the sort order initially (a
in item #1) and then set the "ApplyDefaultSort" property to "true", that i
will overwrite the inital sort ou specificed.... (it is clearly stated i
the documentation)... but thank you anyway

I'm lost then, how does it fit in here or is just extraneous code? Whe
does it get applied b/c the timing of the events with this could easil
explain the problem
2. The last reference (int iRowID System.Convert.ToInt32(dvReturn[j]["DataRowID"].ToString()) is referencing
single row, where "j" is simply an iterator within a "for" loop. I a
copying the contents of each row within the DataView back to an ArrayList.

We need to determine where exactly the problem is. So go ahead and grab th
last value of the datatable in Column0 for instance and see what it is
Then apply the sort and reference that row within the View! Only the vie
is sorted not the datatable. An easy way to do this is make a test grid an
bind to it. Have a button that changes the sort field. Click on it a fe
times and make sure it's sorting correctly. You'll have a visual cue if yo
use a grid. I've never seen this not work and I use it constantly so
suspect it may appear that it's not sorting but it's probably the referenc
to the row
I am interested in your comment re: "j" though... how will "j determine my sort order... ?? Please respond at your convenience, and than
you for the assistance

Whatever j will pass that row regardless of how it's sorted. Basically, i
J is 200 and there are 200 rows, you'll get the last row, but after a sort
if the same row is now position 15, it's only going to be 'correct' when
is 15 Regards

jwede ----- William Ryan eMVP wrote: ----

Jwedel
If you call ApplyDefaultSort after the sort, it will undo the sor yo specified and use the original one. What exactly is that las referenc doing? It looks like you are just referencing one row, so whatever i will determine the sort order. Nonetheless, if you just use Sort lik yo did in the first one, regardless of primary key, you'll sort on tha field "jwedel_stolo" <an*******@discussions.microsoft.com> wrote in messag
news:F0**********************************@microsof t.com..
Hi
I'm creating a dataview "on the fly" in order to sort some dat prio
to writing out the information to a MS SQL table
I have used two methods in order to determine the sort order of th DataView. (I'm writing in C# with the v1.1.4322 of the .NE

Framework, i Window2K server"). First of all, here are the two methods I have use i order to apply the sorting property to the DataView 1. Simply defining the sort orde
and colum DataView dvReturn
string szSort = "DataRowID" + " ASC" vReturn.Sort = szSort
2. Defining a primary key and then
setting the default sort order
property
/// when creating the datatable
first DataTable dt;
dt.PrimaryKey = new DataColumn[]

{dt.Columns["DataRowID"]};
DataView dvFinal = new DataView(dt);
// then set the property

dvFinal.ApplyDefaultSort = true;
When I attempt to access the data from the DataView, the
information is still listed as if it hasn't been sorted. Here is a sample of the code I have implemented in order to retrieve the sorted information (dvReturn would be the DataView I applied the sorting properties to) int iRowID =
System.Convert.ToInt32(dvReturn[j]["DataRowID"].ToString()); int iEmpStatusID = System.Convert.ToInt32(dvReturn[j]["EmpStatusTypeID"].ToString()); Any help would be greatly appreciated, as it is not obvious to
me what I am doing wrong. Thank you in advance. jwedel
>>

Jul 21 '05 #8
Willia
Thanks for all your help. As it turns out, the implementation of the sort and the subsequent accessing of the data is correct. I'm sorting on an integer value. Therefore, if I had an array of integers such as 1,2,13,3... the subsequent sort order will be: 1,13,2,3... I had to preceed the values with a '0' in order to obtain the correct sort order I desired....
(ie; 01, 02, 03, 13... is the sort order I requried).... apologies for wasting your time

regards
jwede

...
Thanks in advance

----- William Ryan eMVP wrote: ----

"jwedel_stolo" <an*******@discussions.microsoft.com> wrote in messag
news:09**********************************@microsof t.com..
William
1. Apologies for the ambiguity.... I have not used the two sortin mechanisms concurrently. I am aware if you set the sort order initially (a
in item #1) and then set the "ApplyDefaultSort" property to "true", that i
will overwrite the inital sort ou specificed.... (it is clearly stated i
the documentation)... but thank you anyway

I'm lost then, how does it fit in here or is just extraneous code? Whe
does it get applied b/c the timing of the events with this could easil
explain the problem
2. The last reference (int iRowID System.Convert.ToInt32(dvReturn[j]["DataRowID"].ToString()) is referencing
single row, where "j" is simply an iterator within a "for" loop. I a
copying the contents of each row within the DataView back to an ArrayList.

We need to determine where exactly the problem is. So go ahead and grab th
last value of the datatable in Column0 for instance and see what it is
Then apply the sort and reference that row within the View! Only the vie
is sorted not the datatable. An easy way to do this is make a test grid an
bind to it. Have a button that changes the sort field. Click on it a fe
times and make sure it's sorting correctly. You'll have a visual cue if yo
use a grid. I've never seen this not work and I use it constantly so
suspect it may appear that it's not sorting but it's probably the referenc
to the row
I am interested in your comment re: "j" though... how will "j determine my sort order... ?? Please respond at your convenience, and than
you for the assistance

Whatever j will pass that row regardless of how it's sorted. Basically, i
J is 200 and there are 200 rows, you'll get the last row, but after a sort
if the same row is now position 15, it's only going to be 'correct' when
is 15 Regards

jwede ----- William Ryan eMVP wrote: ----

Jwedel
If you call ApplyDefaultSort after the sort, it will undo the sor yo specified and use the original one. What exactly is that las referenc doing? It looks like you are just referencing one row, so whatever i will determine the sort order. Nonetheless, if you just use Sort lik yo did in the first one, regardless of primary key, you'll sort on tha field "jwedel_stolo" <an*******@discussions.microsoft.com> wrote in messag
news:F0**********************************@microsof t.com..
Hi
I'm creating a dataview "on the fly" in order to sort some dat prio
to writing out the information to a MS SQL table
I have used two methods in order to determine the sort order of th DataView. (I'm writing in C# with the v1.1.4322 of the .NE

Framework, i Window2K server"). First of all, here are the two methods I have use i order to apply the sorting property to the DataView 1. Simply defining the sort orde
and colum DataView dvReturn
string szSort = "DataRowID" + " ASC" vReturn.Sort = szSort
2. Defining a primary key and then
setting the default sort order
property
/// when creating the datatable
first DataTable dt;
dt.PrimaryKey = new DataColumn[]

{dt.Columns["DataRowID"]};
DataView dvFinal = new DataView(dt);
// then set the property

dvFinal.ApplyDefaultSort = true;
When I attempt to access the data from the DataView, the
information is still listed as if it hasn't been sorted. Here is a sample of the code I have implemented in order to retrieve the sorted information (dvReturn would be the DataView I applied the sorting properties to) int iRowID =
System.Convert.ToInt32(dvReturn[j]["DataRowID"].ToString()); int iEmpStatusID = System.Convert.ToInt32(dvReturn[j]["EmpStatusTypeID"].ToString()); Any help would be greatly appreciated, as it is not obvious to
me what I am doing wrong. Thank you in advance. jwedel
>>

Jul 21 '05 #9
Not a waste of time at all. But that seems weird, what's the datatype of
the column, Int? It looks like a string.
"jwedel_stolo" <an*******@discussions.microsoft.com> wrote in message
news:03**********************************@microsof t.com...
William
Thanks for all your help. As it turns out, the implementation of the sort and the subsequent accessing of the data is correct. I'm sorting on an
integer value. Therefore, if I had an array of integers such as 1,2,13,3...
the subsequent sort order will be: 1,13,2,3... I had to preceed the values
with a '0' in order to obtain the correct sort order I desired..... (ie; 01, 02, 03, 13... is the sort order I requried).... apologies for wasting your time.
regards,
jwedel

...
Thanks in advance.

----- William Ryan eMVP wrote: -----

"jwedel_stolo" <an*******@discussions.microsoft.com> wrote in message
news:09**********************************@microsof t.com...
> William,
> 1. Apologies for the ambiguity.... I have not used the two sorting
mechanisms concurrently. I am aware if you set the sort order initially (as in item #1) and then set the "ApplyDefaultSort" property to "true", that it will overwrite the inital sort ou specificed.... (it is clearly stated in the documentation)... but thank you anyway.

I'm lost then, how does it fit in here or is just extraneous code? When does it get applied b/c the timing of the events with this could easily explain the problem. >> 2. The last reference (int iRowID = System.Convert.ToInt32(dvReturn[j]["DataRowID"].ToString()) is referencing a single row, where "j" is simply an iterator within a "for" loop. I am
copying the contents of each row within the DataView back to an ArrayList..
We need to determine where exactly the problem is. So go ahead and grab the last value of the datatable in Column0 for instance and see what it is. Then apply the sort and reference that row within the View! Only the view is sorted not the datatable. An easy way to do this is make a test grid and bind to it. Have a button that changes the sort field. Click on it a few times and make sure it's sorting correctly. You'll have a visual cue if you use a grid. I've never seen this not work and I use it constantly so I suspect it may appear that it's not sorting but it's probably the reference to the row.
>> I am interested in your comment re: "j" though... how will "j" determine my sort order... ?? Please respond at your convenience, and thank you for the assistance.

Whatever j will pass that row regardless of how it's sorted. Basically, if J is 200 and there are 200 rows, you'll get the last row, but after a sort, if the same row is now position 15, it's only going to be 'correct' when j is 15. >> Regards, > jwedel
>>>> ----- William Ryan eMVP wrote: -----
>> Jwedel:
>> If you call ApplyDefaultSort after the sort, it will undo the sort you
> specified and use the original one. What exactly is that last reference
> doing? It looks like you are just referencing one row, so whatever J is
> will determine the sort order. Nonetheless, if you just use Sort like
you
> did in the first one, regardless of primary key, you'll sort
on that field.
> "jwedel_stolo" <an*******@discussions.microsoft.com> wrote in
message > news:F0**********************************@microsof t.com...
>> Hi,
>> I'm creating a dataview "on the fly" in order to sort some
data prior
> to writing out the information to a MS SQL table.
>> I have used two methods in order to determine the sort order of
the > DataView. (I'm writing in C# with the v1.1.4322 of the .NET

Framework, in
> Window2K server"). First of all, here are the two methods I

have used in
> order to apply the sorting property to the DataView.
>>> 1. Simply defining the sort order
and column >> DataView dvReturn;
>>> string szSort = "DataRowID" + " ASC";
>> vReturn.Sort = szSort;
>>> 2. Defining a primary key and then setting
> the default sort order
>> property
>> /// when creating the datatable

first >> DataTable dt;
>> dt.PrimaryKey = new DataColumn[]

> {dt.Columns["DataRowID"]};
>> DataView dvFinal = new DataView(dt);
>>> // then set the property
>> dvFinal.ApplyDefaultSort = true;
>>> When I attempt to access the data from the DataView, the information
> is still listed as if it hasn't been sorted. Here is a sample

of the code I
> have implemented in order to retrieve the sorted information (dvReturn would
> be the DataView I applied the sorting properties to)
>>> int iRowID =

System.Convert.ToInt32(dvReturn[j]["DataRowID"].ToString()); >> int iEmpStatusID =

>

System.Convert.ToInt32(dvReturn[j]["EmpStatusTypeID"].ToString()); >>> Any help would be greatly appreciated, as it is not obvious

to me what
> I am doing wrong. Thank you in advance.
>>> jwedel
>>>>>>

Jul 21 '05 #10

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

2
by: DraguVaso | last post by:
Hi, I have 2 comboboxes, both bound to a different DataView, but thoe DataViews are bound to 1 DataTable in 1 DataSet. Like this: Dim dvwList2 As New DataView dvwList2 =...
9
by: Raymond Lewallen | last post by:
I have a dataview in which the sort property will not sort the dataview. Here's is a simple scenario similar to what I am doing: Class Foo Private Function Retrieve() As DataView ' Returns a...
1
by: TaeHo Yoo | last post by:
Hi all, After sorting and grouping data using a dataview, then how to transfer the changed datatable in the dataview to a datatable in C#? Cheers
0
by: grolms | last post by:
I must recreated dataview . I am in the designer insert dataview set datasource ... And I set before DataBind datasource on the dataview ... How I recreated dataview. I have dataview in class...
9
by: jwedel_stolo | last post by:
Hi I'm creating a dataview "on the fly" in order to sort some data prior to writing out the information to a MS SQL table I have used two methods in order to determine the sort order of the...
6
by: Nick | last post by:
I have a code that returns data in IList. My webGrid doesn't allow me to sort with IList returned, it say it only suports DataView, DataTable and DataSet, not IEnumerable. I don't know how to...
0
by: Pravin Pujari | last post by:
Hi All, I am using .net framework 1.1 and c#. I have one problem regarding dataview. I have one dataview to which sorting may be applied or may not be applied. I have one UI component where I...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.