慕白兄等各位大哥,帮我看看吧。。。(calendar应用)
private void showInfo(CalendarDay d, TableCell c)
{
DateTime FDate = new DateTime();
string Subject;
SqlCommand objcommand = new SqlCommand();
SqlDataReader objdatareader;
DateTime Date = new DateTime();
Date = d.Date;
ScheduleDA scheduleDadaAccess = new ScheduleDA();
objcommand = scheduleDadaAccess.SchRead(Convert.ToInt16(133), Date);
objcommand.Connection.Open();
objdatareader = objcommand.ExecuteReader();
try
{
while (objdatareader.Read())
{
int ID = Int32.Parse(objdatareader.GetInt32(1).ToString());
FDate = DateTime.Parse(objdatareader.GetSqlDateTime(2).ToString());
string FDate_hour = FDate.Hour.ToString();
string FDate_Minute = FDate.Minute.ToString();
if (FDate_Minute == "0 ")
{
FDate_Minute = "00 ";
}
Subject = objdatareader.GetValue(0).ToString();
if (Subject.Length > 4)
{
Subject = Subject.Substring(0, 4);
Subject += ".. ";
}
HtmlAnchor a = new HtmlAnchor();
a.HRef = "schaddup.aspx?reurl=schedule.aspx&id= " + ID + "&day= " + d.Date.ToShortDateString();
a.InnerText = "★ " + FDate_hour + ": " + FDate_Minute + " " + Subject + " ";
//c.Controls.Add(new LiteralControl( " " + " " + " " + " "));
c.Controls.Add(new LiteralControl( " <br> "));
c.Controls.Add(a);
c.Controls.Add(new LiteralControl( " <br> "));
}
objdatareader.Close();
objcommand.Connection.Close();
}
catch (Exception exc)
{
Response.Write(exc.ToString());
}
}
这段代码,是从数据库中取出日程的具体信息,然后显示在日历控件的每一天的单元格中,假如我在这天创建了3个日程信息,那么这天的单元格内就会显示3条信息,但是我现在能实现的是有多少条信息就显示多少,我怎么才能控制,让每个单元格,也就是每天只显示3条,多了的话,则不显示(显示更多按钮)。。。???
搞了很久也没搞明白。。。
还有一个问题,就是假如我在这一天建立了日程信息,那么这一天就会显示这个信息,但是显示了信息的那天所在的单元格,就会因为显示了信息而与其他的单元格大小高度都不一样,我想把所以的单元格也就是每天,都固定不变?请问是用CSS能控制还是从代码控制呢???
赶紧不尽啊!!!
[解决办法]
int i = 0; while (objdatareader.Read() && i <3){ i++; .....}