Want to protect your cyber security and still get fast solutions? Ask a secure question today.Go Premium

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 229
  • Last Modified:

Arraylist and Datalist

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?

Regards
Praveen
0
praveenuni
Asked:
praveenuni
  • 3
1 Solution
 
laotzi2000Commented:
You can use two datalist side by side
0
 
laotzi2000Commented:
<table>
<tr>
<td>list1</td>
<td>list2</td>
</tr>
</table>

list1 and list2 are the two datalist.

and databind list1 to the first arraylist, databind list2 to the second arraylist
0
 
praveenuniAuthor Commented:
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?

0
 
laotzi2000Commented:
Another way(demonstration only, not exact code):

dim a1 as arraylist
dim a2 as arraylist
dim t as new DataTable
t.columns.add("name")
t.columns.add("value")

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)
next

list.datasource = t
0

Featured Post

What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.

  • 3
Tackle projects and never again get stuck behind a technical roadblock.
Join Now