I have a Dataset from the database which i want to display. My aim is to display a month's data on an aspx page using VS 2005 with 5 days per each row. I have written the code like this but i am confused with the i and j. This code displays nothing.
if (ds != null && ds.Tables[0].Rows.Count > 0)
{
Table table = new Table();
table.ID = "Table1";
TableRow row = new TableRow();
TableCell cell = new TableCell();
TextBox tb1 = new TextBox();
TextBox tb2 = new TextBox();
// I am not sure what i and j should be here to display 5 per each row..
for (int i = 0; i < 5; i++)
{
if (int j == 0; j < ds.Tables[0].Rows.Count; j ++)
{
tb1.ID = "txtDateRow" + x + "Col" + j;
tb1.Text = ds.Tables[0].Rows[x]["Date"].ToString();
tb2.ID = "txtDetails" + x + "Col" + j;
tb2.Text = ds.Tables[0].Rows[x]["AmountSold"].ToString();
cell.Controls.Add(tb1);
cell.Controls.Add(tb2);
table.Rows.Add(row);
}
}
Panel1.Controls.Add(table);
}
If someone could help me solve this, i really appreciate it. Thanks a lot.
tableelement with no rows? The two are very different outcomes.tablebeing added to bothPage.Form.ControlsandPanel1.Controls?