后台代码如下
protected void BindTable(DateTime date)
{
for (int i = 0; i < 6; i++)
{
for (int j = 0; j < 7; j++)
{
tableTime.Rows[i].Cells[j].ID = "td" + i.ToString() + j.ToString();
string id = tableTime.Rows[i].Cells[j].ID;
string newpage = string.Format("window.open('AddEvent.aspx?id={0}','新建/修改事务','height=660,width=1200,toolbar=no,location=no,menubar=no,top=100,left=200')", id);
tableTime.Rows[i].Cells[j].Attributes.Add("onclick",newpage);
TextBox tb = new TextBox();
tb.Text = "wwww";
tb.ID = "tb" + i.ToString() + j.ToString();
tb.Width = Unit.Parse("30px");
tableTime.Rows[i].Cells[j].Controls.Add(tb);
}
}
前台部分代码:就是给tabletime的每个td添加textbox