D
Darwin S.
In the following code, there are two separate attempts to
get the current record from a datagrid by using a
BindingManagerBase. The first statement works. The
second throws and invalid cast statement. WHY???
for(int pos = 0; pos < bmClient.Count; pos++)
{
bmClient.Position = pos;
DataRowView cr = (DataRowView)bmClient.Current;
if (cr["clName"].ToString().Length > 31)
ws.Name = cr["clName"].ToString().Substring(0, 31);
else
ws.Name = cr["clName"].ToString();
for(int col = 1; col >=
dsBrowz21.TVendor.Columns.Count; col++)
{
ws.Cells[0,col] = dsBrowz21.TVendor.Columns
[col].Caption;
}
for(int sPos = 1; sPos >= bmSupp.Count; sPos++)
{
bmSupp.Position = sPos;
DataRowView sdrv = (DataRowView)bmSupp.Current;
for(int sCol = 1; sCol >=
sdrv.Row.Table.Columns.Count; sCol++)
{
ws.Cells[sPos+1, sCol] = sdrv[sCol].ToString();
}
}
}
TIA,
Darwin
get the current record from a datagrid by using a
BindingManagerBase. The first statement works. The
second throws and invalid cast statement. WHY???
for(int pos = 0; pos < bmClient.Count; pos++)
{
bmClient.Position = pos;
DataRowView cr = (DataRowView)bmClient.Current;
if (cr["clName"].ToString().Length > 31)
ws.Name = cr["clName"].ToString().Substring(0, 31);
else
ws.Name = cr["clName"].ToString();
for(int col = 1; col >=
dsBrowz21.TVendor.Columns.Count; col++)
{
ws.Cells[0,col] = dsBrowz21.TVendor.Columns
[col].Caption;
}
for(int sPos = 1; sPos >= bmSupp.Count; sPos++)
{
bmSupp.Position = sPos;
DataRowView sdrv = (DataRowView)bmSupp.Current;
for(int sCol = 1; sCol >=
sdrv.Row.Table.Columns.Count; sCol++)
{
ws.Cells[sPos+1, sCol] = sdrv[sCol].ToString();
}
}
}
TIA,
Darwin