|
web
newsgroups
|
|||||||||||||||||||||||
|
|||||||||||||||||||||||
Edit a rowHi,
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 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 Show quoteHide quote "jayasunde***@gmail.com" wrote: > 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 > > 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 Kerry Moorman wrote: Show quoteHide quote > 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 > > > "jayasunde***@gmail.com" wrote: > > > 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 > > > > 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 Show quoteHide quote "Jay" wrote: > 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 > > Kerry Moorman wrote: > > 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 > > > > > > "jayasunde***@gmail.com" wrote: > > > > > 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 > > > > > > > > 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 Show quoteHide quote "Kerry Moorman" <KerryMoor***@discussions.microsoft.com> schreef in bericht news:AF6FD686-CB18-45C4-A7A8-8B9A673E2028@microsoft.com... > 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 > > > "Jay" wrote: > >> 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 >> >> Kerry Moorman wrote: >> > 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 >> > >> > >> > "jayasunde***@gmail.com" wrote: >> > >> > > 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 >> > > >> > > >> >> thanks people i fixed the problem. I appreciate everyone's feedback
Jay Cor Ligthert [MVP] wrote: Show quoteHide quote > 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 > > "Kerry Moorman" <KerryMoor***@discussions.microsoft.com> schreef in bericht > news:AF6FD686-CB18-45C4-A7A8-8B9A673E2028@microsoft.com... > > 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 > > > > > > "Jay" wrote: > > > >> 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 > >> > >> Kerry Moorman wrote: > >> > 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 > >> > > >> > > >> > "jayasunde***@gmail.com" wrote: > >> > > >> > > 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 > >> > > > >> > > > >> > >>
2005 too smart for it's own good?
A Question on VB Classes Controls of a form convert html string into a html document read file without locking it. Reading text files How to convert an Image file to PDF file Doubling up of data in DataView-bound DataGrid?? buttons stopped working Position to a Brazilian software developer ? |
|||||||||||||||||||||||