No dataview item property

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"]);
....
}
 
F

Francois Bonin [C# MVP]

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

HTH,
Cois
 
E

Earl

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"]);
...
}
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Similar Threads


Top