Hi, I'd like to use a typed row to iterate through a DatarowView array. I've
used a view for its FindRows method.
How (or where) can I cast this so that the rows & rowViews will work
together. I've tried converting them in various places without success:
Thanks for any ideas. I can use an untyped in the loop but I'm sure this
must be able to be done.
Ant
// Tried converting here with no success
DataView dv = new DataView(dsMaster.Customers);
dv.Sort = "City";
DataRowView[] dr = dv.FindRows("London");
// Doesn't like this. Tried converting here as well
foreach (dsMaster.CustomersRow cr in dr)
{
MessageBox.Show(cr.City.ToString());
}
Try
foreach(DataRowView drv in dr)
{
dsMaster.CustomersRow cr = drv.Row as dsMaster.CustomersRow;
if (null != cr)
{
MessageBox.Show(cr.City.ToString());
}
}
> Hi, I'd like to use a typed row to iterate through a DatarowView array. I've
> used a view for its FindRows method.
[quoted text clipped - 20 lines]
> MessageBox.Show(cr.City.ToString());
> }
Ant - 30 Apr 2006 13:38 GMT
Hi Mark,
Thanks very much for demystifying that for me. It works fine.
Regards
Ant
> Try
> foreach(DataRowView drv in dr)
[quoted text clipped - 30 lines]
> > MessageBox.Show(cr.City.ToString());
> > }