No dataview item property

  • Thread starter Thread starter Earl
  • Start date Start date
E

Earl

This was initially posted on the C# forum and was meant to be cross-posted
here.

Noting first that I'm coming from VS2003 and VB.Net to C# and VS2005 ...

Using an untyped dataset, I create a dataview. When I try to use the Item
property, "Item" does not appear on the Intellisense dropdown and I also get
the build error "'System.Data.DataView' does not containt a definition for
'Item'." The documentation for VS2005 does show Item as a property of a
dataview -- can anyone see the issue?

DataView dvContacts = new DataView(ds.Tables["dtContacts"]);
int intCounter = dvContacts.Count;

for (intCounter = 0; intCounter < -1; intCounter++)
{
intContactID =
System.Convert.ToInt32(dvContacts.Item(intCounter).Column["ContactID"]);
....
}
 
the Items property in C# is replaced by an indexer.
So you can use this:
System.Convert.ToInt32(dvContacts[intCounter].Column["ContactID"]);

HTH,
Cois
 
Thanks Francois. That's an alternative idea but I ended up using the syntax
suggested by Steven Nagy:

dvContacts[intCounter]["ContactID"];

Francois Bonin said:
the Items property in C# is replaced by an indexer.
So you can use this:
System.Convert.ToInt32(dvContacts[intCounter].Column["ContactID"]);

HTH,
Cois

Earl said:
This was initially posted on the C# forum and was meant to be
cross-posted here.

Noting first that I'm coming from VS2003 and VB.Net to C# and VS2005 ...

Using an untyped dataset, I create a dataview. When I try to use the Item
property, "Item" does not appear on the Intellisense dropdown and I also
get
the build error "'System.Data.DataView' does not containt a definition
for
'Item'." The documentation for VS2005 does show Item as a property of a
dataview -- can anyone see the issue?

DataView dvContacts = new DataView(ds.Tables["dtContacts"]);
int intCounter = dvContacts.Count;

for (intCounter = 0; intCounter < -1; intCounter++)
{
intContactID =
System.Convert.ToInt32(dvContacts.Item(intCounter).Column["ContactID"]);
...
}
 
Back
Top