PC Review


Reply
Thread Tools Rate Thread

Accessing a DataRow by name

 
 
=?UTF-8?B?TWFydGluIFDDtnBwaW5n?=
Guest
Posts: n/a
 
      26th Aug 2006
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
 
Reply With Quote
 
 
 
 
Nicholas Paldino [.NET/C# MVP]
Guest
Posts: n/a
 
      26th Aug 2006
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]
- (E-Mail Removed)

"Martin Pöpping" <(E-Mail Removed)> wrote in message
news:ecpg5e$932$(E-Mail Removed)...
> 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



 
Reply With Quote
Reply

Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Accessing the current DataRow of the DataSource from ItemDataBound Nathan Sokalski Microsoft ASP .NET 5 25th Sep 2005 03:10 PM
Accessing the current DataRow of the DataSource from ItemDataBound Nathan Sokalski Microsoft VB .NET 5 25th Sep 2005 03:10 PM
Accessing Selected DataRow from DataGrid =?Utf-8?B?RmxlY2ttYW4=?= Microsoft Dot NET Framework Forms 4 17th Aug 2004 05:07 PM
Exception accessing DataRow column value Shravan Microsoft C# .NET 0 13th Nov 2003 05:41 AM
VersionNotFoundException when accessing column value from DataRow Shravan Microsoft Dot NET Framework Forms 0 8th Oct 2003 10:13 AM


Features
 

Advertising
 

Newsgroups
 


All times are GMT +1. The time now is 08:18 PM.