Wrox Programmer Forums

Need to download code?

View our list of code downloads.

| FAQ | Members List | Search | Today's Posts | Mark Forums Read
BOOK: ASP.NET 2.0 Website Programming Problem Design Solution ISBN: 978-0-7645-8464-0
This is the forum to discuss the Wrox book ASP.NET 2.0 Website Programming: Problem - Design - Solution by Marco Bellinaso; ISBN: 9780764584640
Welcome to the p2p.wrox.com Forums.

You are currently viewing the BOOK: ASP.NET 2.0 Website Programming Problem Design Solution ISBN: 978-0-7645-8464-0 section of the Wrox Programmer to Programmer discussions. This is a community of tens of thousands of software programmers and website developers including Wrox book authors and readers. As a guest, you can read any forum posting. By joining today you can post your own programming questions, respond to other developers’ questions, and eliminate the ads that are displayed to guests. Registration is fast, simple and absolutely free .
DRM-free e-books 300x50
 
 
Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old December 20th, 2007, 04:36 PM
Registered User
 
Join Date: Aug 2007
Location: Gilbert, AZ, USA.
Posts: 4
Thanks: 0
Thanked 0 Times in 0 Posts
Default How to reference field by name

I'm fairly new to c# and I hope there is already an easy way to do this.

After using the BLL to read an Article, I want to use a variable to reference the individual field names. i.e.,

Article["Title"] would give me the value of Article.Title.

The quoted field name are coming from an array and won't include every field in the Article.

Thanks for any help.



  #2 (permalink)  
Old December 21st, 2007, 06:34 AM
Friend of Wrox
 
Join Date: Mar 2007
Location: Creetown, UK
Posts: 488
Thanks: 2
Thanked 11 Times in 10 Posts
Default

dsr771 - this is just my opinion. i don't think it's a great idea to bypass strongly types variables, as further down the line, you are bound to make some changes to the structure (or scaling it up) that will cause a lot of reworking. i'm just curious to know why you propose using the array, rather than using the article class from the BLL. there would be no 'expense' in using the the article class even if you didn't want to use all of the properties.

there is obviously a reason why you want to go down this route (reflection??) and if that were described, then i think it'd be perhaps easier to address the issue above based on your reasoning.

all the best for now

jimi

http://www.originaltalent.com
  #3 (permalink)  
Old December 21st, 2007, 03:49 PM
Registered User
 
Join Date: Aug 2007
Location: Gilbert, AZ, USA.
Posts: 4
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Quote:
quote:Originally posted by jimibt
 dsr771 -
there is obviously a reason why you want to go down this route (reflection??) and if that were described, then i think it'd be perhaps easier to address the issue above based on your reasoning.

all the best for now

jimi

http://www.originaltalent.com
Thanks for the reply. I do want to use the object for most functions. I ran into a problem where I have form fields on multiple tabs of a ajax tab container and asp.net doesn't see those controls and does not update the data. So I'm building a workaround since my project requires use of tabs with data fields on more than one tab.

I'm writing code in the ItemUpdating event to find the control on the correct tab and copy the values back to the FormUpdateEventArgs e.

I use:
oldData = BLL.Aritlces.Article.GetArticleByID(x);
then I loop a hash table that defines my fields and which tabpanel they are on. Then search for the control SelTabPanel.FindControl(), then:

e.OldValues[key] = oldData[key]; // I want to do this instead of oldDate.ColumnName
e.NewValues[key] = txtBox.Text;

I suppose if I could convert oldData to a DataRow or something.

This process does save my data and it works well to monitor changes.

I welcome any ideas. Hope this makes sense.
 


Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

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 Off
HTML code is Off
Trackbacks are Off
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Replace Gridview field if null with new field Indo77 ASP.NET 2.0 Basics 1 June 18th, 2007 06:22 AM
Updating a Date field based on another field arholly Access VBA 6 November 22nd, 2006 11:19 AM
Reference ADO Recordset Field after CommitTrans U.N.C.L.E. Classic ASP Professional 5 November 21st, 2006 03:20 AM
Copy previous field record if next field is null ecampos Access VBA 6 June 23rd, 2006 12:55 PM
Update city field based on zip field nganb SQL Server ASP 0 April 22nd, 2004 10:30 PM



All times are GMT -4. The time now is 07:23 AM.


Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
© 2013 John Wiley & Sons, Inc.