Help: BindingManagerBase problem

  • Thread starter Thread starter Darwin S.
  • Start date Start date
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
 
-----Original Message-----
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();
}
}
}

bmSupp is a BindingManagerBase class of a DataGrid whose
datasource is the detail from a master.detail
relationship. bmSupp.Current.GetType() returns
System.Data.DataViewManagerListItemTypeDescriptor. I
can't find any information about the type. What do I do
with it? I'm confused. Any help would be appreciated.

Thanks,
Darwin
 
Back
Top