Click here to Skip to main content
15,887,135 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
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)

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.
C#
//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]));
}
 
Share this answer
 
v4
Write code like this,

C#
for(int i =0;i<arr.Length;i++)
{
 write("<tr><td>" + arr[i++] + "</td><td>" + arr[i] + "</td></tr>";
}
 
Share this answer
 
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.
see this reference

Array List Values[^]
 
Share this answer
 
v2

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



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900