R8VI
asked on
Create table dynamically and isnert data c#, asp.net
Hi,
I have the code below.
What I want to do is create the rows and cells and insert the data dynamically, but this seems like a loop that does not end please helps
dgFindClient.Rows.Count is set to 2
I have the code below.
What I want to do is create the rows and cells and insert the data dynamically, but this seems like a loop that does not end please helps
dgFindClient.Rows.Count is set to 2
//// Create a new table
DocumentFormat.OpenXml.Wordprocessing.Table tbl = new DocumentFormat.OpenXml.Wordprocessing.Table();
int icountRowsinService = dgFindClient.Rows.Count;
int icounterfortableservice;
for (icounterfortableservice = 0; icounterfortableservice < icountRowsinService; icountRowsinService++)
{
//// Create a new row
DocumentFormat.OpenXml.Wordprocessing.TableRow tr = new DocumentFormat.OpenXml.Wordprocessing.TableRow();
//// Add a cell to each column in the row
DocumentFormat.OpenXml.Wordprocessing.TableCell tablecellService = new DocumentFormat.OpenXml.Wordprocessing.TableCell(new Paragraph(new Run(new Text("Vijai"))));
DocumentFormat.OpenXml.Wordprocessing.TableCell tablecellServicePrice = new DocumentFormat.OpenXml.Wordprocessing.TableCell(new Paragraph(new Run(new Text("1"))));
//// Add the cells to the row
tr.Append(tablecellService, tablecellServicePrice);
//// Add the rows to the table
tbl.AppendChild(tr);
}
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Old loop statement: for (icounterfortableservice = 0; icounterfortableservice < icountRowsinService; icountRowsinService++)
New loop statement: for (icounterfortableservice = 0; icounterfortableservice < icountRowsinService; icounterfortableservice++)
Check the variable used in ++
New loop statement: for (icounterfortableservice = 0; icounterfortableservice < icountRowsinService; icounterfortableservice++)
Check the variable used in ++
If you keep increasing icountRowsinService loop will never end.
ASKER