The reason your code is only generating the number of steps equal to the number of rows you have in your database is because the for loop in your code (see below) that does the iterations for you will only execute the amount of times directly equivalent
to the number of records returned by your query
foreach (DataRow row in dt.Rows) // if your table contains three records this loop will only execute three times
{
}
To create the remaining steps you will need to add an addition loop after your loop to create the additonal steps e.g.
rowcount = dt.Rows.Count;
for(int i=rowcount +1; i <= 25; i++) //this loop will starting from the number of records returned until it reaches 25
{
lit_steps.Text += "<li><a href=steps.aspx?step=" + i + "&QID=" + QID + ">Step " + i + "</a> Progress - " + 0 + "</li>";
}
Hope this helps
Please mark as answer if this resolved your problem
bakra
Member
342 Points
59 Posts
Re: Assign a database field value to a menu item (step)
Apr 01, 2012 12:03 AM|LINK
The reason your code is only generating the number of steps equal to the number of rows you have in your database is because the for loop in your code (see below) that does the iterations for you will only execute the amount of times directly equivalent to the number of records returned by your query
foreach (DataRow row in dt.Rows) // if your table contains three records this loop will only execute three times
{
}
To create the remaining steps you will need to add an addition loop after your loop to create the additonal steps e.g.
rowcount = dt.Rows.Count;
for(int i=rowcount +1; i <= 25; i++) //this loop will starting from the number of records returned until it reaches 25
{
lit_steps.Text += "<li><a href=steps.aspx?step=" + i + "&QID=" + QID + ">Step " + i + "</a> Progress - " + 0 + "</li>";
}
Hope this helps
Please mark as answer if this resolved your problem