Jump to content
Xtreme .Net Talk

Recommended Posts

Posted

I'm having a problem on sorting a dataset after I insert a new row and call the

 

AcceptChanges of the dataset.

 

I sort a dataset like this:

 

ds.Tables(0).DefaultView.Sort = SortField

 

But this will not work. The new record is still located at the end of the dataset. I see this when I populate a listview with the dataset.

 

I hope someone can help me. Thanks!

Posted

Maybe you could get the DefaultView and set the SortExpression.

 

It work for me all the time.

"If someone say : "Die mortal !"... don't stay to see if he isn't." - Unknown

"Learning to program is like going out with a new girl friend. There's always something that wasn't mentioned in the documentation..." - Me

"A drunk girl is like an animal... it scream at everything like a cat and roll in the grass like a dog." - Me after seeing my girlfriend drunk and some of her drunk friend.

C# TO VB TRANSLATOR

  • Moderators
Posted

George, that's not an option, he is already using the Sort method of the defaultview.

 

Arch4ngel, he's already doing that.

 

Auxcom, it doesn't matter if it's a grid or listview, did you bind after you sorted?

Visit...Bassic Software
Posted

Bang! 3 in 1 for Robby.

 

Last solution...

Did you bind ? :p

"If someone say : "Die mortal !"... don't stay to see if he isn't." - Unknown

"Learning to program is like going out with a new girl friend. There's always something that wasn't mentioned in the documentation..." - Me

"A drunk girl is like an animal... it scream at everything like a cat and roll in the grass like a dog." - Me after seeing my girlfriend drunk and some of her drunk friend.

C# TO VB TRANSLATOR

Posted

I like to edit my reply at post #3:

I dont use a datagrid. I use a listview and I think there is no databinding w/ a listview.

 

Here is my code for filling my listview.

 

Private Function FillView() As Integer

Dim dr As DataRow

Dim lvi As ListViewItem

 

ds.Tables(0).DefaultView.Sort = "Username ASC"

 

lvw.Items.Clear()

For Each dr In ds.Tables(0).Rows

lvwUser.Items.Add(dr("Username"))

Next

End Function

  • *Experts*
Posted

Try something like this instead:

 


Dim dr As DataRowView
lvw.Items.Clear()

For Each dr In ds.Tables(0).DefaultView
   lvwUser.Items.Add(dr("Username"))
Next

"I want to stand as close to the edge as I can without going over. Out on the edge you see all the kinds of things you can't see from the center." - Kurt Vonnegut
Posted

Thanks Nerseus!

 

It already work the way I want :-)

 

I just add this line of code before the looping

 

ds.Tables(0).DefaultView.Sort = "Username ASC"

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...