473,387 Members | 1,578 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,387 software developers and data experts.

No Item in C# ?

I found several code examples on the net but this doesn't want to work.

Label2.Text = filesIDData1.Tables["Files"].Rows[2].Item["TP_Name"];

There isn't a Item property in C# while all the examples have one. How
should I do this? I need the value of the field TP_Name of the
selected row (just put 2 there for now) .

I found another msg on usegroups with the same question but no answer.
--
Kind regards,

Stijn Verrept.
Nov 18 '05 #1
6 1144
Stijn,

I don't know if this will work but in vb.net the syntax can use item or omit
item like this:

Label2.Text = filesIDData1.Tables("Files").Rows(2)("TP_Name")

You could see if the same works in c# (I haven't tested it myself):

Label2.Text = filesIDData1.Tables["Files"].Rows[2]["TP_Name"];

--
Sincerely,

S. Justin Gengo, MCP
Web Developer / Programmer

Free code library at:
www.aboutfortunate.com

"Out of chaos comes order."
Nietzche
"Stijn Verrept" <stijn@no_s.p.a.n.entrysoft.com> wrote in message
news:40**********************@news.skynet.be...
I found several code examples on the net but this doesn't want to work.

Label2.Text = filesIDData1.Tables["Files"].Rows[2].Item["TP_Name"];

There isn't a Item property in C# while all the examples have one. How
should I do this? I need the value of the field TP_Name of the
selected row (just put 2 there for now) .

I found another msg on usegroups with the same question but no answer.
--
Kind regards,

Stijn Verrept.

Nov 18 '05 #2
Try

filesIDData1.Tables["Files"].Rows[0]["TP_Names"]

--
Shiv R. Kumar
http://www.matlus.com
"Stijn Verrept" <stijn@no_s.p.a.n.entrysoft.com> wrote in message
news:40**********************@news.skynet.be...
I found several code examples on the net but this doesn't want to work.

Label2.Text = filesIDData1.Tables["Files"].Rows[2].Item["TP_Name"];

There isn't a Item property in C# while all the examples have one. How
should I do this? I need the value of the field TP_Name of the
selected row (just put 2 there for now) .

I found another msg on usegroups with the same question but no answer.
--
Kind regards,

Stijn Verrept.

Nov 18 '05 #3
Hello Stijn,

"Stijn Verrept" <stijn@no_s.p.a.n.entrysoft.com> schrieb im Newsbeitrag
news:40**********************@news.skynet.be...
I found several code examples on the net but this doesn't want to work.

Label2.Text = filesIDData1.Tables["Files"].Rows[2].Item["TP_Name"];

try
Label2.Text = filesIDData1.Tables["Files"].Rows[2]["TP_Name"];
Nov 18 '05 #4
Shiv Kumar wrote:
Try

filesIDData1.Tables["Files"].Rows[0]["TP_Names"]


This is it! Thanks a lot, you too Justin.

--
Kind regards,

Stijn Verrept.
Nov 18 '05 #5
Simon Gorski wrote:
Hello Stijn,

"Stijn Verrept" <stijn@no_s.p.a.n.entrysoft.com> schrieb im
Newsbeitrag news:40**********************@news.skynet.be...
I found several code examples on the net but this doesn't want to
work.

Label2.Text = filesIDData1.Tables["Files"].Rows[2].Item["TP_Name"];

try
Label2.Text = filesIDData1.Tables["Files"].Rows[2]["TP_Name"];


Works great thanks!

--
Kind regards,

Stijn Verrept.
Nov 18 '05 #6

"Stijn Verrept" <stijn@no_s.p.a.n.entrysoft.com> wrote in message
news:40**********************@news.skynet.be...
I found several code examples on the net but this doesn't want to work.

Label2.Text = filesIDData1.Tables["Files"].Rows[2].Item["TP_Name"];

There isn't a Item property in C# while all the examples have one. How
should I do this? I need the value of the field TP_Name of the
selected row (just put 2 there for now) .

I found another msg on usegroups with the same question but no answer.
--
Kind regards,

Stijn Verrept.


As an explanation of the other answers: if you look at the MSDN docs for the
Item method, then you see a line "In C#, this property is the indexer for
the <classname> class."
For languages that do not support the indexer syntax, you can use the Item
method.
C# does support indexers, so you can ignore "Item" and just use [].

Hans Kesting
Nov 18 '05 #7

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

13
by: tuvok | last post by:
I have an Item object which allocates memory in its ctor and frees it in its dtor. I want to add such items to a vector. But the program crashes. Why? How do I fix it? #include <vector> ...
2
by: Ash Jones | last post by:
I trying to do nested items in a collection. I've got an item which one of the properties is subitems, which is a collection of item. can do the root level but if i do a subitem at design time i...
7
by: Devron Blatchford | last post by:
Hi there, I have created an owner draw menu item using DrawItem and MeasureItem in VB.NET. This seems to work well. I was wondering how I can do mouse over effects in these menus. Basically the...
3
by: Dean Slindee | last post by:
In a checked listbox, I am allowing drag/drop of the items within (resequencing). Problem is, when dropping a checked item, the checked state always reverts to unchecked (unwanted). Anyone know...
18
by: JohnR | last post by:
From reading the documentation, this should be a relatively easy thing. I have an arraylist of custom class instances which I want to search with an"indexof" where I'm passing an instance if the...
3
by: Steve Long | last post by:
I hope this isn't too stupid of a question but I'm looking for a way to change an item in a listview control when the mouse moves over it. I'd like to change its color and underline it for a...
6
by: George | last post by:
Hi all, How can I get the value stored from the selected item and subitems of a listview? Thanks in advance, George
1
by: HKSHK | last post by:
Hi guys, I have a problem with the combo box I'm writing on. What I want is custom items, which are fine so far, but when I select one the combo box shows the project name...
3
by: Bmack500 | last post by:
I have a sub, and a class. The sub is like this: Sub dothis() Dim aInfoListX As New infoWrapperClass aInfoListX.params = ReadConfig() Dim sqlCMD As New SqlCommand aInfoListX.sqlCmd = sqlCMD ...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.