Arraylist and Datalist

Posted on 2005-03-21
Medium Priority
Last Modified: 2006-11-17
I'm using C# as code-behind language.
I have 2 arraylists (name, value) of equal length. I want to display the values in the array lists on my webpage using datalist. I want to display them in such a way that 1st value in 'name' arraylist should be next to 1st value in 'value' arraylist and so on. (The result should be like 2 columns and 'length of arraylist' rows). How can I achieve this?

Question by:praveenuni
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 3
LVL 12

Expert Comment

ID: 13594647
You can use two datalist side by side
LVL 12

Expert Comment

ID: 13594669

list1 and list2 are the two datalist.

and databind list1 to the first arraylist, databind list2 to the second arraylist

Author Comment

ID: 13594731
I cannot do that because,
value of 'name' arraylist [i] = value of 'value' arraylist'[i]

sometimes both the values are not coming up exactly side - by-side, which is a problem. To eliminate all the issues I want to display them with one datalist using the arraylists. Is there a possiblity of condensing both the arraylists into one and then displaying the data using datalist?

LVL 12

Accepted Solution

laotzi2000 earned 2000 total points
ID: 13594877
Another way(demonstration only, not exact code):

dim a1 as arraylist
dim a2 as arraylist
dim t as new DataTable

dim i as integer
for i = 0 to a1.length
  dim r as datarow = t.rows.newrow()
  r("name") = a1(i)
  r("value") = a2(i)

list.datasource = t

Featured Post

On Demand Webinar: Networking for the Cloud Era

Did you know SD-WANs can improve network connectivity? Check out this webinar to learn how an SD-WAN simplified, one-click tool can help you migrate and manage data in the cloud.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

This article discusses the ASP.NET AJAX ModalPopupExtender control. In this article we will show how to use the ModalPopupExtender control, how to display/show/call the ASP.NET AJAX ModalPopupExtender control from javascript, how to show/display/cal…
A quick way to get a menu to work on our website, is using the Menu control and assign it to a web.sitemap using SiteMapDataSource. Example of web.sitemap file: (CODE) Sample code to add to the page menu: (CODE) Running the application, we wi…
Have you created a query with information for a calendar? ... and then, abra-cadabra, the calendar is done?! I am going to show you how to make that happen. Visualize your data!  ... really see it To use the code to create a calendar from a q…
In this video, Percona Solutions Engineer Barrett Chambers discusses some of the basic syntax differences between MySQL and MongoDB. To learn more check out our webinar on MongoDB administration for MySQL DBA: https://www.percona.com/resources/we…
Suggested Courses
Course of the Month10 days, 11 hours left to enroll

765 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question