473,513 Members | 2,477 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Two DataBind questions

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.

Nov 18 '05 #1
1 1437
> 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

"ASP Yaboh" <AS******@discussions.microsoft.com> wrote in message
news:18**********************************@microsof t.com... 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.

Nov 18 '05 #2

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

Similar topics

0
1395
by: autofill | last post by:
2 scenario inside a WebUserControl. I want to know why Microsoft and so many book doesn't suggest us to work like that. This control going to be in my page and I will call the DataBind of my...
3
11994
by: Marty McDonald | last post by:
I have <asp:Table... </asp:Table> on my webform. In codebehind, I populate a DataTable whose data should appear in the asp:Table. I created my own code to populate the asp:Table with the...
1
1883
by: Thomas Jespersen | last post by:
Hello How do I databind a ASP.NET Texbox to a custom object. I a WinForm I do it like this: Dim myCustomerObject As Customer() Private Sub CreateNewCustomer myCustomerObject = New...
10
11586
by: aualias | last post by:
This seems like such a lame question, but how do you bind to a CheckBox with ASP.NET? With Windows Forms there is a DataBindings collection. I do not see it with the web version of the control,...
2
1762
by: Jim Bancroft | last post by:
Hi everyone, I have a DropDownList I populate as outlined below. This is from my code-behind file: private void Page_Load(object sender, System.EventArgs e) { BindMyData(); DataBind(); }
11
4640
by: Rourke Eleven | last post by:
I have looked and searched. What good is the databind property on Radiobuttons? How does one go about actually using it? What is a good resource on this? I understand that I can easily get/set...
2
1091
by: Adam J Knight | last post by:
Hi all, I am trying to bind a value to a hyperlink control. For some reason it isn't working. What have i missed? <asp:HyperLink ID="lnkQuestions" NavigateUrl='Questions.aspx?ID=<%#...
2
1734
by: zhshqzyc | last post by:
Hi, I am going to create two aspx pages. The first page will display the whole content of a table which is from a DataSet. DataSet myDataSet = new DataSet(); try { ...
6
1852
by: Jonathan Wood | last post by:
I have a databound dropdownlist control. Based on some other criteria, I need to specify the selected item in my pages Load event. The problem is that, in my load event, the control does not yet...
0
7260
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
7162
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
7384
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
7539
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...
1
7101
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
7527
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
4746
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...
0
3223
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
0
456
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence...

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.