D
DIOS
I have unique setup which requires me to query several different
databases and then populate on DataGridView in my VB2005 app. All that
is working great but now I have the challenge of taking that DGV data
and converting it to a DataTable as there is an existing and rather
complicated subroutine that only takes a datatable as its argument.
Anyway an example of the dataset that I bind to the dgv initially
SELECT LONG_FIELD_XXXYY FROM SOURCE1;
-or-
SELECT JUST_AS_LONG_FIELDZZZZ FROM SOURCE2;
These are very simplified but I have way more fields than this and I
choose to change the dgv headers once the data is displayed like so
dgv.Columns("LONG_FIELD_XXXYY").HeaderText = "UserName"
-or-
dgv.Columns("JUST_AS_LONG_FIELDZZZZ ").HeaderText = "UserName"
The idea being the end user will see standard headers in the DGV
regardless of where the data came from. Again up to this point that is
working great. My goal now is to iterate either through the DGV or the
datatable that contains a copy of the data. But every time I do this
with
drow.Item("UserName")
-or-
drow.Cells("UserName").Value
I get an error that the field UserName does not exist. I think the
grid or table still use the underlying database field name and thus I
cant use the alias of the header. Is this true? Is there any way that
I can use my standard header of UserName to get cell values. I cant
figure out how to do this either with a DGV or a DataTable.
Any suggestions appreciated.
AGP
databases and then populate on DataGridView in my VB2005 app. All that
is working great but now I have the challenge of taking that DGV data
and converting it to a DataTable as there is an existing and rather
complicated subroutine that only takes a datatable as its argument.
Anyway an example of the dataset that I bind to the dgv initially
SELECT LONG_FIELD_XXXYY FROM SOURCE1;
-or-
SELECT JUST_AS_LONG_FIELDZZZZ FROM SOURCE2;
These are very simplified but I have way more fields than this and I
choose to change the dgv headers once the data is displayed like so
dgv.Columns("LONG_FIELD_XXXYY").HeaderText = "UserName"
-or-
dgv.Columns("JUST_AS_LONG_FIELDZZZZ ").HeaderText = "UserName"
The idea being the end user will see standard headers in the DGV
regardless of where the data came from. Again up to this point that is
working great. My goal now is to iterate either through the DGV or the
datatable that contains a copy of the data. But every time I do this
with
drow.Item("UserName")
-or-
drow.Cells("UserName").Value
I get an error that the field UserName does not exist. I think the
grid or table still use the underlying database field name and thus I
cant use the alias of the header. Is this true? Is there any way that
I can use my standard header of UserName to get cell values. I cant
figure out how to do this either with a DGV or a DataTable.
Any suggestions appreciated.
AGP