In a master page
I am trying to create a dynamic table with 4 columns for a table row.
Actual my requirement is I have text box in which I will give a number basing on that number input it should create 4 column's in a row
ex: in my text box i/p is 5 then table should created in the below format
| Label1 | TetBox1 | Label2 | TextBox2 |
| Label3 | TextBox3 | Label4 | TextBox4 |
| Label5 | TextBox5 |
in this first column Level1 and textbox1 in 2nd column in the same way third column and fourth column's level2 and textbox2
in the above mentioned format my dynamic table should be created.
I have tried but recieving an error. Help is needed ASAP, As I stuck with this functionality

ali tuncerPosted Mar 4, 2016, 2:46 AM
Now you are creating a table with id "tabletxtRoundNumber" in server side, with this line:
Phani KumarPosted Mar 4, 2016, 2:27 AM
ali tuncerPosted Mar 4, 2016, 2:13 AM
could be related to css, or you might be creating them in a wrong place(could be wrong div,table,td..), if functionality is working, that part should be easier!
Phani KumarPosted Mar 4, 2016, 2:03 AM
ali tuncerPosted Mar 4, 2016, 1:57 AM
Hi Phani,
Phani KumarPosted Mar 4, 2016, 1:17 AM
Phani KumarPosted Mar 4, 2016, 1:10 AM
ali tuncerPosted Mar 4, 2016, 1:07 AM
Hi Phani,
That's the problem, you are trying to add rows to a table with id "tabletxtRoundNumber" in your page but it doesn't exist. You need to fix that part..you should look for a table id that exist in the page..
Phani KumarPosted Mar 4, 2016, 1:00 AM
Amit KumarPosted Mar 4, 2016, 12:34 AM
ali tuncerPosted Mar 4, 2016, 12:25 AM
What does this line return? is it null? Probably this part has problem..
Table table = // new Table();
Phani KumarPosted Mar 3, 2016, 11:55 PM
Phani KumarPosted Mar 3, 2016, 11:46 PM
Phani KumarPosted Mar 3, 2016, 11:40 PM
theLizardPosted Mar 3, 2016, 4:53 PM
{
int boxes=0, rows = 0, i=0, t=1, perrow = 0, k=0;
decimal j = 0;
int.TryParse(TextBox2.Text, out perrow);
int.TryParse(TextBox1.Text, out boxes);
string s = "
j = boxes;
if ( j % perrow != 0)
{
rows = (int)j/perrow + 1;
}
else
rows = (int)j / perrow;
for (i = 0; i < rows; i++)
{
s += "
for (k = 0; k < perrow; k++)
{
s = AddRow(s, t);
t++;
boxes--;
if (boxes == 0)
break;
}
if (k % perrow == 0)
s += "
}
s += "
TableDiv.InnerHtml = s;
}
private string AddRow(string s, int t)
{
s += "
s += "
return (s);
}
.auto-style1 {
width: 139px;
}