Two DataBind questions

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

1. If I use an ArrayList as my data source, how do I construct the accessor
methods? That is, forget about properties for a moment, if I wanted the 5th
item in the ArrayList, I would write the method:

public string getTheField(int index) { ... } - where index would equal 4.

How is this written into the property? Does reflection take care of getting
the appropriate value?


2. Expanding on that, say I have an ArrayList of ArrayLists where the inner
ArrayLists correspond to rows in a database resultset. So, here the 5th field
in the outer ArrayList gets the 5th deeper ArrayList which is the 5th row of
data. Can the methods/properties be constructed to do this? If so, cold you
provide a brief example of the syntax. It would clear up some questions I
have. (I'm translating some old JSP code.)

Thank you for your time.
 
1. If I use an ArrayList as my data source, how do I construct the
accessor
methods? That is, forget about properties for a moment, if I wanted the 5th
item in the ArrayList, I would write the method:

public string getTheField(int index) { ... } - where index would equal 4.

How is this written into the property? Does reflection take care of getting
the appropriate value?

(Scratching my head for a moment...)

An ArrayList is an existing Collection, which can be used in DataBinding.
Other than that, I can't make sense of your question. An ArrayList already
has a get and set method for the Item property. Neither of them have much of
anything to do with databinding. And you certainly don't need to define
("construct") them.
2. Expanding on that, say I have an ArrayList of ArrayLists where the inner
ArrayLists correspond to rows in a database resultset. So, here the 5th field
in the outer ArrayList gets the 5th deeper ArrayList which is the 5th row of
data. Can the methods/properties be constructed to do this? If so, cold you
provide a brief example of the syntax. It would clear up some questions I
have. (I'm translating some old JSP code.)

(Going to get some aspirin for my head...)

The first "road" went off track somewhere. The second "road" expands on
that, which means we're both totally lost now.

Maybe you could try again?

--
HTH,
Kevin Spencer
..Net Developer
Microsoft MVP
I get paid good money to
solve puzzles for a living
 
Back
Top