473,397 Members | 2,099 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,397 software developers and data experts.

Accessing a DataRow by name

Hello,

I´ve a problem with accessing the fields of a data row.

I created a row of my table "Metainfos":

private fp_databaseDataSet.MetainfosRow newMetainfosRow;

and then I can access for example the field "JournalName" in this
Metainfos-Table:

this.newMetainfosRow.JournalName
My question is now, if there is any solution to access the field with
using a variable like:

String field = "JournalName"

and then something like

this.newMetainfosRow.Field(field)

or something like that.

Regards,

Martin
Aug 26 '06 #1
1 1346
Martin,

Yes, there is, you use the indexer, like this:

this.newMetainfosRow["JournalName"]

Note that you have to cast the return value to the type that you want,
in this case, it seems like a string, so you should do this:

string field = "JournalName"

string value = (string) this.newMetainfosRow[field];

Hope this helps.
--
- Nicholas Paldino [.NET/C# MVP]
- mv*@spam.guard.caspershouse.com

"Martin Pöpping" <ma******@despammed.comwrote in message
news:ec**********@newsreader2.netcologne.de...
Hello,

I´ve a problem with accessing the fields of a data row.

I created a row of my table "Metainfos":

private fp_databaseDataSet.MetainfosRow newMetainfosRow;

and then I can access for example the field "JournalName" in this
Metainfos-Table:

this.newMetainfosRow.JournalName
My question is now, if there is any solution to access the field with
using a variable like:

String field = "JournalName"

and then something like

this.newMetainfosRow.Field(field)

or something like that.

Regards,

Martin

Aug 26 '06 #2

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

Similar topics

2
by: George Grodentzik | last post by:
I created a typed dataset from which I am trying to access the data. When I use the following code to access a row string name =dataset.person.firstName I receive an error...
1
by: Yama | last post by:
Hi, I have the following loaded into a dataset: <xml version="1.0" encoding="UTF-16"> <xml xmlns:s="uuid:BDC6E3F0-6DA3-11d1-A2A3-00AA00C14882"...
3
by: shamila | last post by:
we are trying to pass a value to format a value in the datacolumn. But when we pass the datacolumn , it does not give me the value in the column, instead gives me the column name. the following...
3
by: Darren Clark | last post by:
I am trying to understand typed datasets more.... and i am stuck on a little problem I have created a type dataset called "News" this consists of 2 tables. NewsTable and NewsTypes. the news has...
0
by: N. Demos | last post by:
Hello, I'm having problems accessing a complex XML child node (latitude & longitude), and passing it to a function when the XML file has been read into a DataSet. Specifically, the returned object...
2
by: paolol | last post by:
Hi, I wont to get the current row values from a dataset, any one know how to reach those data ?? At the moment I use a work around, but it's not good .. foreach (DataRow row in...
1
by: Arpan | last post by:
This is how I am dynamically adding a table to a DataSet: <script runat="server"> Sub Page_Load(ByVal obj As Object, ByVal ea As EventArgs) 'Create an empty DataSet Dim dSet As New DataSet ...
2
by: Tony Girgenti | last post by:
Hello I developed and tested a web application using VS.NET 2003, VB, .NET Framework 1.1.4322, ASP.NET 1.1.4322 and IIS5.1. It uses a web form. I used the XML Designer to create an XML .XSD...
4
by: SteveT | last post by:
I am wanting to populate several treeviews, one for the <TRs> group and one for the <TGsgroup. Is there a simplier way to populate the Treeview than the one I did below? It seems difficult to...
10
by: mcbobin | last post by:
Hi, Here's hoping someone can help... I'm using a stored procedure to return a single row of data ie a DataRow e.g. public static DataRow GetManualDailySplits(string prmLocationID, string
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
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
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...

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.