我做了一个asp.net的页面C#写的,页面里有两个div 一个是<div id="doctorId" runat="server"></div> 另一个是 <div id="weekScheduler_dayRow" runat="server"></div>。
然后在后台cs里面,doctorId.Controls.Clear();weekScheduler_dayRow.Controls.Clear();
然后根据一个已经存放好数据的SortedList<DateTime, List<tableDoc>> totallist = new SortedList<DateTime, List<tableDoc>>();进行赋值。
for (int i = 0; i < totallist.Count; i++)
{
HtmlGenericControl div_doc = getDiv(null, "", "10", null);
for (int j = 0; j < totallist.Values[i].Count; j++)
{
int id = int.Parse(totallist.Values[i][j].Id);
HtmlGenericControl hdiv = getDivHour(j.ToString() + id.ToString(), id.ToString(), "", null, false);
div_doc.Controls.Add(hdiv);
} doctorId.Controls.Add(div_doc);
//以上是第一个div的赋值,以下是第二个div的赋值
int dcount = totallist.Values[i].Count;
listCapacity = listCapacity + dcount;
HtmlGenericControl div_day = getDiv(null, "days", (divWidth * dcount).ToString(), null);
HtmlGenericControl div_weekday;
if (doctor_count == 1)
{
div_weekday = getDiv(totallist.Keys[i].ToString("M月d日 (ddd)"), "weekDay", (divWidth - 1).ToString(), (headerHeight * 2).ToString());
}
else
{
if (dcount == 1)
{
div_weekday = getDiv(totallist.Keys[i].ToString("M\\/d(ddd)"), "weekDay", (divWidth * dcount - 1).ToString(), null);
}
else
{
div_weekday = getDiv(totallist.Keys[i].ToString("M月d日(ddd)"), "weekDay", (divWidth * dcount - 1).ToString(), null);
}
}
div_weekday.ID = "day_" + listCapacity +"_" + totallist.Keys[i].ToString("yyyy-M-d");
div_day.Controls.Add(div_weekday);
if (doctor_count > 1)
{
//int qcount = queryEmp.Count();
int cc = 1;
foreach (var d in totallist.Values[i])
{
string name = string.Empty;
if (d.Value == 1)
{
name =js1+d.Id+js2+ d.Text+js3;
}
else
{
name =js1+d.Id+ js2+ d.Name+js3;
}
HtmlGenericControl div_doctor = getDiv(name, "doctor", (divWidth - 1).ToString(), null);
if (cc == dcount)
{
div_doctor.Style.Add("border-right", "1px solid #00008B");
}
div_day.Controls.Add(div_doctor);
cc++;
}
}
weekScheduler_dayRow.Controls.Add(div_day);
}
问题是,我第一次载入页面时候,一切正常,然后我在页面上有一个链接,点击这个链接会发一个ajax请求再到这个页面,然后重新装载数据,这时候,我发现ajax请求重新刷页面的时候,第一个div仍然显示第一次刷新的数据,而第二个div显示再次装载的数据,这让我非常费解!甚至是百思不得其解!为什么呢?这是为什么呢?请哪位高手给答疑解惑~~ 鞠躬感谢!
楼主你如果仅仅是查询数据的话,刷新页面后还是会回到第一次请求页面状态的,html代码是.cs直接输出的而不是ajax请求后组装的数据...