Could someone help me, figure out why is that my new table always display the last row of data only.
the code goes like this:
string connection_string = @"Data Source=.;Initial Catalog=calendar;Integrated Security=True";
SqlConnection conn;
SqlCommand cmd;
SqlDataReader dr;
string cssMonth = "calMonth";
int i = 0;
string[] dateTo;
string[] dateFrom;
string[] events;
private void displayCalendarEvents()
{
TableRow tRow = new TableRow();
TableCell cellMonth = new TableCell();
TableCell cellDateTo = new TableCell();
TableCell cellDateFrom = new TableCell();
TableCell cellEvents = new TableCell();
int num = setEvents(); // the number of selected events in the database i.e. 2 rows
for (int i = 0; i < num; i++)
{
tRow.CssClass = cssMonth;
cellDateTo.Text = dateTo[i].ToString();
cellDateFrom.Text = dateFrom[i].ToString();
cellEvents.Text = events[i].ToString();
tRow.Cells.Add(cellDateTo);
tRow.Cells.Add(cellDateFrom);
tRow.Cells.Add(cellEvents);
calendarTable.Rows.Add(tRow);
}
}
the "calendarTable" is an asp:Table control