You can use one line of code to create a dataview from the datatable.
Dim dv as DataView = WhateverDataTable.DefaultView
Now, bind the grid to the view instead of the table. All of your
current
functionality will still be in tact.
You can call Sort on any field in the dataview and sort it which will
cause
the grid to sort.You could offer this via a context menu for instance,
if
for some reason you didn't want to allow sorting based on the grid
headers.
dim dv As New DataView
dv = ds.Tables(0).DefaultView 'where ds is the dataset in question
dv.Sort = "Order" 'where Order is the column name by which you want to sort
Me.DataGrid1.DataSource = dv
Me.DataGrid1.Refresh()
Talkin about dataview object. Recently I tried to edit some row like this
.... dr(indexcolumn) (indexrow) = "... " .. it was applied to the dataset,
But it didn't update to the datasource when i call
DataAdapter.update(Dataset,"TableName") { this with assumtion that
commandbuilder had been generated }. And also a mistake when i tried to
delete row using dataview object. But it didn't show any error message when
i put the -update method- in try ... catch ... endtry ....
Felling frustated with dataview object .. i used datatable object to edit
and delete row. ... Did u guys have this kind of problems before ?
Yes I did. I added beginedit and endedit and the problems were gone. I
thought begin/endedit was optional but it looks like it is obliged.
Frank
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.