mercredi 1 avril 2015

Typed Data Row - insert bata based on the column name

I have a table where I am storing data based on certain criteria. Both tables are typed tables.

tblShipper has around 10 columns and tblParsedData has 3 columns(ID, FieldName, FieldValue)


I created a row from tblShipper, to add FieldValue for each column. However, as we know typed row will show column names.


I cant find a way to do something like the code below or something better.



MyDataset.tblShipperRow _newRow = _tblShipper.NewtblShipperRow();
foreach(tblParsedDataRow _row in _parsedDataForShipper.Rows)
_newRow[_row.FieldName] = _row.FieldValue;
_tblShipper.Rows.Add(_newRow);


More details:

tblParsingParams stores parameters, we use these parameters to read data from file, parse the data that we read and store it in key/value format in tblParsedData.


tblParsedData has fields like: key, value, tablename (table for which this data is), columnname.


On run time, I am created a dataset for tblShipper or any other table, then I am loading data from tblParsedData into data table. Now I need to insert data from tblParsedData data table into tblShipper Dataset. Bind this dataset to a gridview, so that user can view and verify/edit the data, and later save it into database (tblShipper).


Duplicate: Insert data into typed row on the fly based on column name






Aucun commentaire:

Enregistrer un commentaire