Click here to Skip to main content
14,269,538 members
Rate this:
Please Sign up or sign in to vote.
See more:
dear sir,
I have a array list. i need to create a report.How to pass array list value like as following

Actual array list:

12DBT183843IYP
950.00
12DBT183843YP
1137.00


I need to generate a report like this

Doc no: Amount
12DBT183843IYP 950.00
12DBT183843YP 1137.00

Please help me
Posted
Comments
V. 30-Mar-12 8:51am
   
What have you tried? What technology are you using to create the report? (word, cognos, crystal reports, ...)
stanly jeba singh 30-Mar-12 8:59am
   
I am using c# code behind Response.Write("<tr>");(HTML format)
Rate this:
Please Sign up or sign in to vote.

Solution 2

The solution 1 works for ArrayList also. Since, the counter i is incremented inside the for loop, I have put a little check to ensure that the loop does not throw error when the arr.Length (for array list arr.Count) is odd.
//Better option is to use generic List<string>
//List<string> arr = new List<string>()
//{"12DBT183843IYP","950.00","12DBT183843YP","1137.00","Fifth"};
ArrayList arr = new ArrayList(){"12DBT183843IYP","950.00","12DBT183843YP","1137.00","Fifth"};
for(int i =0;i<arr.Count/2*2;i++)
{
    Response.Write(string.Format("<tr><td>{0}</td><td>{1}</td></tr>\n",arr[i++], arr[i]));
}
   
v4
Rate this:
Please Sign up or sign in to vote.

Solution 1

Write code like this,

for(int i =0;i<arr.Length;i++)
{
 write("<tr><td>" + arr[i++] + "</td><td>" + arr[i] + "</td></tr>";
}
   
Comments
ProEnggSoft 30-Mar-12 12:47pm
   
Good. +5
fjdiewornncalwe 30-Mar-12 16:18pm
   
Sorry, but this code won't work as it is written.
Rate this:
Please Sign up or sign in to vote.

Solution 3

see this reference

Array List Values[^]
   
v2

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)




CodeProject, 503-250 Ferrand Drive Toronto Ontario, M3C 3G8 Canada +1 416-849-8900 x 100