Home All Groups Group Topic Archive Search About

No dataview item property

Author
11 Jul 2006 8:47 PM
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"]);
....
}

Author
13 Jul 2006 2:58 PM
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

Show quote
"Earl" <brikshoe@newsgroups.nospam> wrote in message
news:%23OWDGtSpGHA.3564@TK2MSFTNGP03.phx.gbl...
> 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"]);
> ...
> }
>
>
Author
13 Jul 2006 5:15 PM
Earl
Thanks Francois. That's an alternative idea but I ended up using the syntax
suggested by Steven Nagy:

dvContacts[intCounter]["ContactID"];

Show quote
"Francois Bonin [C# MVP]" <thec***@gmail.com> wrote in message
news:Os%23OKvopGHA.2148@TK2MSFTNGP03.phx.gbl...
> 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" <brikshoe@newsgroups.nospam> wrote in message
> news:%23OWDGtSpGHA.3564@TK2MSFTNGP03.phx.gbl...
>> 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"]);
>> ...
>> }
>>
>>
>
>

AddThis Social Bookmark Button