datalist 在运行时生成代码:如何在页面回发后访问 datalist 元素的值?
void CreateDATELIST(Control container)
{
var st = settings.CustomPossition();
foreach (var item in settings.CustomPossition())
{
DataTable dt = new DataTable();
dt.Columns.Add("Name");
dt.Columns.Add("Possition");
dt.Columns.Add("Production");
dt.Columns.Add("dpo");
dt.Columns.Add("WorkDay");
DataRow dr;
foreach (var users in item.Users)
{
dr = dt.NewRow();
dr["Name"] = users.Name;
dr["Possition"] = users.Position.Name;
dr["Production"] = users.DailyGoalAmount * (double)(users.WorkDays / 12;
dr["dpo"] = users.DailyGoalAmount;
dr["WorkDay"] = users.WorkDays;
dt.Rows.Add(dr);
dt.AcceptChanges();
}
DataList dataList = new DataList();
dataList.ItemTemplate = Page.LoadTemplate("Commnets.ascx");
container.Controls.Add(dataList);
dataList.DataSource = dt;
dataList.DataBind();
}
}