我有一个数据库,其中包含一个保存资源的表(用户名基本上用于webschedule控件)。我一直在尝试为每个资源动态创建webscheduleinfo,以便我可以为每个用户显示webdayview。我可以稍微做一些,但我必须在网页设计中设置预定义数量的webschedule控件和webscheduleinfo。我遇到的问题是,在调用webscheduleinfo_resourcesfetched方法之前,我无法访问资源列表。这是我现在的代码。
public partial class Calendar : System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
{
}
protected void WebScheduleInfo1_ResourcesFetched(object sender, EventArgs e)
{
ResourcesCollection resources = WebScheduleInfo1.VisibleResources;
int count = resources.Count;
Resource obje = (Resource)resources.GetItem(1);
string name = obje.Name;
resources.Clear();
resources.Add(obje);
this.WebScheduleInfo1.ActiveResourceName = name;
}
protected void WebScheduleInfo2_ResourcesFetched(object sender, EventArgs e)
{
ResourcesCollection resources = WebScheduleInfo2.VisibleResources;
int count = resources.Count;
Resource obje = (Resource)resources.GetItem(2);
string name = obje.Name;
resources.Clear();
resources.Add(obje);
this.WebScheduleInfo2.ActiveResourceName = name;
}
protected void WebScheduleInfo3_ResourcesFetched(object sender, EventArgs e)
{
ResourcesCollection resources = WebScheduleInfo3.VisibleResources;
int count = resources.Count;
Resource obje = (Resource)resources.GetItem(3);
string name = obje.Name;
resources.Clear();
resources.Add(obje);
this.WebScheduleInfo3.ActiveResourceName = name;
}
protected void WebScheduleInfo4_ResourcesFetched(object sender, EventArgs e)
{
ResourcesCollection resources = WebScheduleInfo4.VisibleResources;
int count = resources.Count;
Resource obje = (Resource)resources.GetItem(4);
string name = obje.Name;
resources.Clear();
resources.Add(obje);
this.WebScheduleInfo4.ActiveResourceName = name;
}
protected void WebScheduleInfo5_ResourcesFetched(object sender, EventArgs e)
{
ResourcesCollection resources = WebScheduleInfo5.VisibleResources;
int count = resources.Count;
Resource obje = (Resource)resources.GetItem(6);
string name = obje.Name;
resources.Clear();
resources.Add(obje);
this.WebScheduleInfo5.ActiveResourceName = name;
}
}