473,671 Members | 2,206 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 1441
> 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******@discu ssions.microsof t.com> wrote in message
news:18******** *************** ***********@mic rosoft.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
1416
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 user control. PAGE page_load(....) { if(!IsPostBack) { this.WebUserControl1.DataBind();
3
12015
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 DataTable, then I discovered the asp:Table has a DataBind method. But the method takes no args and so I'm confused how to use it. Is there a link to see how DataBind works for asp:Table? Should I just use my own code anyway? Thanks... Here's my...
1
1894
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 Customer() myCustomerObject.FirstName = "Thomas"
10
11598
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, but there is a DataBinding event. Thanks. AU
2
1767
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
4651
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 the information I need programmatically, but what about the databind property I just don't understand it's value.
2
1096
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=<%# DataBinder.Eval(Container.DataItem,"ID")%>' Runat="server">view questions</asp:HyperLink>
2
1741
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 { myConnection.Open(); // create the data
6
1855
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 have any data. I've found I can call DataBind() on that control and then it works okay. However, this has me wondering where the control normally databinds, and if me doing it manually would actually introduce the overhead of having the control...
0
8472
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, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
8819
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 tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
8596
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 Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
8667
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 protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
7428
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
6222
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 presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
5690
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 then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
4221
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
2
1801
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 can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.