Click here to Skip to main content
15,887,477 members
Please Sign up or sign in to vote.
1.00/5 (2 votes)
See more:
Dear Sir i have some data with rows and column as folows:
manas   20 10 30 80 40 50 60 70
mani    11 12 13 14 15 16 17 18
mami    21 22 23 24 25 26 27 28
raju    22 33 44 55 66 77 88 89
sajit   42 15 45 11 22 10 20 25

i want to split the data like
it will read first 3 rows and 4 columns.like
manas   20 10 30 
mani    11 12 13 
mami    21 22 23 


then
raju    22 33 44 
sajit   42 15 45 

then
80 40 50 60
14 15 16 17
24 25 26 27

then
55 66 77 88
11 22 10 20


code:
XML
for (int i = 0; i < lstRows.Count; i++)
       {
           int counter = 1;
           for (int j = NoOffixedcolumn; j < lstColumns.Count; j++) //Check with no of columns
           {
               lines += lstRows[i].ChildNodes[j].InnerText + " "; //lstColumns[j].InnerText.ToString();
               if (counter % NoOfColumn == 0)//When it is equla with your no of columns upto last stage
               {
                   Response.Write(lines + "<br/>");
                   lines = fixColumns + " ";
               }
               if (j == lstColumns.Count - 1 && counter % NoOfColumn != 0) //Check at last column
               {
                   Response.Write(lines + "<br/>");
               }
               counter += 1;
           }
       }
Posted
Updated 8-Jul-13 8:47am
v3
Comments
ZurdoDev 8-Jul-13 13:30pm    
What's the question?
Akbar Ali Hussain 8-Jul-13 13:40pm    
Are you providing the info or facing any issue and asking for help?
Maciej Los 8-Jul-13 15:28pm    
Completely not understandable!
Please, be more specific and provide more details.

1 solution

Since the printing is pretty much hard coded my advice is to create a data strcture and store rows and column indexes in it.

for example

C#
Index[0] >= print row[0]col[0] to row[2]col[3]
Index[1] >= print row[3]col[0] to row[4]col[3]

Index[2] >= print row[0]col[4] to row[2]col[8]
Index[3] >= print row[3]col[4] to row[4]col[8]

and do an iteration on the index. Hopefully this should sort your problem
 
Share this answer
 
v2
Comments
Maciej Los 9-Jul-13 2:24am    
Please, use text formatting.

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