各位大峡进来帮帮忙阿!
最近要做一个日程安排的模块,要是那种使用日历显示的,点击日历的某一天可这天做日程安排添加没有问题,但是就是如何把添加了的记录,在日历上相对应的显示在日历下方,
如何绑定?
我使用的 calendar控件 如图 我在15号添加一个安排
但是老是绑定的是最后一天的安排 前面14号 ,13,12 号的数据都没有绑定上来,大加帮我看看
这个是日期 dv.Table.Rows[i]["User_age"]
这个是要绑定的标题 dv.Table.Rows[i]["User_name"]
protected void calSchedule_DayRender(object sender, DayRenderEventArgs e)
{
DataView dv=DAL.Dataaccessing.Get_Dataaccessing.Exec_SqlDataview("select * from test1");
CalendarDay d = ((DayRenderEventArgs)e).Day;
TableCell c = ((DayRenderEventArgs)e).Cell;
if (d.IsOtherMonth)
{
c.Controls.Clear();
}
else
{
try
{
Label hl = new Label();
hl.ToolTip = "新增个人日程";
hl.ID="hl"+d.Date.ToShortDateString();
for(int i=0;i<dv.Table.Rows.Count;i++)
{
if(Convert.ToDateTime(dv.Table.Rows[i]["User_age"]).ToString("yyyy-MM-dd")==d.Date.ToString("yyyy-MM-dd"))
{
hl.Text ="<br />"+dv.Table.Rows[i]["User_name"].ToString();
}
else
{
hl.Text ="";
}
}
c.Controls.Add(hl);
}
catch (Exception ex)
{
Response.Write(ex.ToString());
}
}
} --------------------编程问答-------------------- mark
--------------------编程问答-------------------- private void Page_Load(object sender, System.EventArgs e)
{
this.monthDoc.Load(Server.MapPath("dayRenderData.xml"));
}
private void Calendar1_DayRender(object sender, ComponentArt.Web.UI.CalendarDayRenderEventArgs e)
{
string dayNumber = e.DayRenderInfo.DayNumberText;
string monthIndex = (e.DayRenderInfo.Date.Month % 4).ToString();
e.Output.Write(dayNumber + "<br />");
XmlNode dayNode = this.monthDoc.SelectSingleNode("/months/month[@index=" + monthIndex + "]/day[@number=" + dayNumber + "]");
if (dayNode != null)
{
XmlNodeList dayItems = dayNode.SelectNodes("item");
foreach (XmlNode dayItem in dayItems)
{
e.Output.Write(dayItem.InnerXml);
e.Output.Write("<br />");
}
}
} --------------------编程问答-------------------- mark 2 --------------------编程问答-------------------- 帮顶+学习
可以参考代码:
private void Page_Load(object sender, System.EventArgs e)
{
this.monthDoc.Load(Server.MapPath("dayRenderData.xml"));
}
private void Calendar1_DayRender(object sender, ComponentArt.Web.UI.CalendarDayRenderEventArgs e)
{
string dayNumber = e.DayRenderInfo.DayNumberText;
string monthIndex = (e.DayRenderInfo.Date.Month % 4).ToString();
e.Output.Write(dayNumber + " <br />");
XmlNode dayNode = this.monthDoc.SelectSingleNode("/months/month[@index=" + monthIndex + "]/day[@number=" + dayNumber + "]");
if (dayNode != null)
{
XmlNodeList dayItems = dayNode.SelectNodes("item");
foreach (XmlNode dayItem in dayItems)
{
e.Output.Write(dayItem.InnerXml);
e.Output.Write(" <br />");
}
}
}
补充:.NET技术 , ASP.NET