Edit a row

J

jayasunderam

Hi,
I am a vb.net novice. I have a datatable which is populated with the
data from sql query.
dt = datastore.GetDataTable(GetSql(uid, bin))
I want to edit each row in the datatable with new values but before
they are binded to the datagrid. what would be the best way to do it.
Any leads would be great
thanks
Jay
 
G

Guest

Jay,

You could use a For Each loop to process each row.

For Each dr As DataRow in dt.Rows
'Process row dr
Next

Kerry Moorman
 
J

Jay

I am updating the rows by getting values from another array. the array
is not sorted. I am not sure in which order the array will have
data.therefore i need to read the data from array and update the
corresponding row in the table.
any suggestions
thanks
 
G

Guest

Jay,

You could sort both the datatable and the array on the same data element.

Or you could create a dataview from the datatable and use its Find method to
find the row that matches data from the array.

Kerry Moorman
 
C

Cor Ligthert [MVP]

Kerry,

You are using a strongly typed datatable, that one is forever inherited from
a non strongly typed datatable

The main format of that is that it are two collection.
DataRows
DataColumns

DataRows have items which are described in the datacolumns.

You can forever get an item as
DataTable.DataRows(TheRowIndex).Item(TheDataColumnName or the "DataItemname"
or the Index)

This patern is of course as well in the strongly dataset. Most people don't
like to use the strongly typed datsets to do updating as you do, because
getting the right row is forever troublefull. Therefore cast it to a
standard datatable and use that.

I hope this gives an idea,

Cor
 

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.

Ask a Question

Top