|
web
newsgroups
|
|||||||||||||||||||||||
|
|||||||||||||||||||||||
move rows in a dataviewHi,
Sorting the dataview will reorder the records. You might have to add a column to the datatable for sorting Dim strConn As String Dim ds As New DataSet Dim strSQL As String Dim daEmployees As OleDbDataAdapter Dim conn As OleDbConnection strConn = "Provider = Microsoft.Jet.OLEDB.4.0;" strConn &= "Data Source = Northwind.mdb;" conn = New OleDbConnection(strConn) da = New OleDbDataAdapter("Select * From Categories", conn) da.Fill(ds, "Categories") Dim dcSort As New DataColumn("First", GetType(Integer)) ds.Tables("Categories").Columns.Add(dcSort) Trace.WriteLine("Before sort") Dim dv As New DataView(ds.Tables("Categories")) For Each drvCategories As DataRowView In dv Trace.WriteLine(drvCategories.Item("Description")) Next For Each drvCategories As DataRowView In dv drvCategories.Item("First") = 1 Next dv.Item(4).Item("First") = 0 dv.Sort = "First" Trace.WriteLine("After sort") For Each drvCategories As DataRowView In dv Trace.WriteLine(drvCategories.Item("Description")) Next Ken --------------------- "Sam" <samuel.berthe***@voila.fr> wrote in message How can I move a row in my dataview to the first position ?news:1119869864.674019.250790@g49g2000cwa.googlegroups.com... Hi, Thx |
|||||||||||||||||||||||