数据库表 table1
id(主键),userid(用户ID),date(日期),event(事件,行程)页面添加日历控件,后台根据点击的时间用datediff()函数查询数据表中的date字段
然后用sqldatareader读出
如果dr里没数据,则该天没有事件或行程
有数据则显示

解决方案 »

  1.   

    用.net的Calendar控件啊,下面再放一个label或者别的用来显示数据的控件
     然后定义一个str=Calendar1.SelectedDate.ToShortDateString()
    在数据表ca中设置id,date,thing 三个字段,
    查询数据库 select thing from ca where date = str
    OK,把查询结果赋给label.text就可以了
      

  2.   

    我要实现的功能是等于这个页面就是一个日历.在这个日历的每天上面就直接写做的事了.
    Calendar控件不可能实现
      

  3.   

    你去CSDN的下载里面去下载 有类似的范例
    不过
    我实现了这个功能
    哈哈
    我做了彩票日历
    和你说的一样
    我的日历
    不是用日历控件做的
    是用反射
    自己构成的
    我做的效果页面是这个
    http://hemai.hnticai.com/LotteryCalendar/Calendar.aspx?date=2007-11-8
    你去看吧
    嘎嘎
    一样能实现我的这个效果滴
      

  4.   

    <%@ Page Language="C#" AutoEventWireup="true" CodeFile="LunZhiBiao.aspx.cs" Inherits="AOA_RenShi_LunZhiBiao" %><!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
    <html xmlns="http://www.w3.org/1999/xhtml">
    <head runat="server">
        <title>无标题页</title>
        <link href="../../App_Themes/styles.css" rel="stylesheet" type="text/css" />
    </head>
    <body>
        <form id="form1" runat="server">
            <div>
                <center>
                    <table border="0" cellpadding="0" cellspacing="0" style="width: 840px">
                        <tr>
                            <td colspan="7" style="font-weight: bold; font-size: 18px; font-family: 新宋体; text-align: center;">
                                天津航标处<asp:Label ID="lblMonth" runat="server"></asp:Label>月干部轮值表&nbsp;
                                <asp:Button ID="btnManage" runat="server" PostBackUrl="~/AOA/RenShi/LunZhiBiao_Manage.aspx"
                                    Text="管理" Visible="False" /></td>
                        </tr>
                        <tr>
                            <td style="width: 120px; height: 23px" class="tr2">
                                周一</td>
                            <td style="width: 120px; height: 23px" class="tr2">
                                周二</td>
                            <td style="width: 120px; height: 23px" class="tr2">
                                周三</td>
                            <td style="width: 120px; height: 23px" class="tr2">
                                周四</td>
                            <td style="width: 120px; height: 23px" class="tr2">
                                周五</td>
                            <td style="width: 120px; height: 23px; color: green;" class="tr2">
                                周六</td>
                            <td style="width: 120px; height: 23px; color: red;" class="tr2">
                                周日</td>
                        </tr>
                        <tr>
                            <td style="height: 15px;" colspan="7" align="left" valign="top">
                                <asp:DataList ID="dlDays" runat="server" RepeatColumns="7" RepeatDirection="Horizontal" OnItemDataBound="dlDays_ItemDataBound">
                                    <ItemTemplate>
                                        <center>
                                        <asp:Label ID="lblDay" runat="server" Font-Size="18px" Font-Bold="true"></asp:Label>
                                        </center>
                                        <br />
                                        <asp:MultiView ID="mvDay" runat="server">
                                            <asp:View ID="vWeekDay" runat="server">
                                                <asp:Label ID="lblEmployee" runat="server"></asp:Label>
                                                &nbsp;&nbsp;<br /> 手机:<asp:Label ID="lblMobile" runat="server"></asp:Label></asp:View>
                                            <asp:View ID="vWeekEnd" runat="server">
                                                <font color="navy">白天:</font><br />
                                                <asp:Label ID="lblDayEmployee" runat="server"></asp:Label>
                                                &nbsp;&nbsp; <br />手机:<asp:Label ID="lblDayMobile" runat="server"></asp:Label><br />
                                                <font color="navy">夜间:</font><br />
                                                <asp:Label ID="lblNightEmployee" runat="server"></asp:Label>
                                                &nbsp;&nbsp; <br />手机:<asp:Label ID="lblNightMobile" runat="server"></asp:Label></asp:View>
                                        </asp:MultiView>
                                    </ItemTemplate>
                                    <AlternatingItemStyle Width="120px" Height="120px" BorderColor="Black" BorderWidth="1px" VerticalAlign="Top" />
                                    <ItemStyle Width="120px" Height="120px" BorderColor="Black" BorderWidth="1px" VerticalAlign="Top" />
                                </asp:DataList></td>
                        </tr>
                    </table>
                </center>
            </div>
        </form>
    </body>
    </html>
      

  5.   

    using System;
    using System.Data;
    using System.Configuration;
    using System.Collections;
    using System.Web;
    using System.Web.Security;
    using System.Web.UI;
    using System.Web.UI.WebControls;
    using System.Web.UI.WebControls.WebParts;
    using System.Web.UI.HtmlControls;
    using Microsoft.Practices.EnterpriseLibrary.Data;
    using HangBiao.AOA.Common;
    using TedaBus.RFPrincipal;public partial class AOA_RenShi_LunZhiBiao : AppPage
    {
        Database db = DatabaseFactory.CreateDatabase("HangBiao");    protected override void OnInit(EventArgs e)
        {
            base.OnInit(e);
        }
        
        protected void Page_Load(object sender, EventArgs e)
        {
            bool showManage = false;        System.Security.Principal.IPrincipal p = Context.User;
            if (p != null)
            {
                SitePrincipal user = p as SitePrincipal;
                if (user != null)
                {
                    if (user.HasPermission((int)UserPermission.办公室_值班表管理))
                    {
                        showManage = true;
                    }
                }
            }        btnManage.Visible = showManage;
            
            lblMonth.Text = DateTime.Today.Month.ToString();
            
            ArrayList alBind = new ArrayList();
            string year = DateTime.Today.Year.ToString();
            string month = DateTime.Today.Month.ToString();
            DutyBLL bll = new DutyBLL(db);
            ArrayList alDuty = bll.GetByMonth(year, month);
            int firstPos = (alDuty[0] as DutyData).GetDayInWeek();
            for (int i = 0; i < firstPos; i++)
            {
                DutyData lastMonthDuty = new DutyData();
                lastMonthDuty.DutyDate = (alDuty[0] as DutyData).DutyDate.AddDays(i - firstPos);
                alBind.Add(lastMonthDuty);
            }
            foreach (object obj in alDuty)
            {
                alBind.Add(obj);
            }
            dlDays.DataSource = alBind;
            dlDays.DataBind();
        }
        protected void dlDays_ItemDataBound(object sender, DataListItemEventArgs e)
        {
            if (e.Item.ItemType == ListItemType.AlternatingItem || e.Item.ItemType == ListItemType.Item)
            {
                DutyData data = e.Item.DataItem as DutyData;
                Label lblDay = e.Item.FindControl("lblDay") as Label;
                MultiView mvDay = e.Item.FindControl("mvDay") as MultiView;
                if (data.DutyDate.Month == DateTime.Today.Month)
                {
                    lblDay.Text = data.DutyDate.Day.ToString();
                    if (data.DutyDate == DateTime.Today)
                    {
                        e.Item.BackColor = System.Drawing.Color.LightPink;
                    }
                }
                else
                {
                    mvDay.Visible = false;
                    e.Item.BorderWidth = 0;
                }
                
                if (data.DayEmployee == string.Empty)
                {
                    mvDay.ActiveViewIndex = 0;
                    Label lblEmployee = mvDay.FindControl("lblEmployee") as Label;
                    lblEmployee.Text = data.NightEmployee;
                    Label lblMobile = mvDay.FindControl("lblMobile") as Label;
                    lblMobile.Text = data.NightMobile;
                }
                else
                {
                    mvDay.ActiveViewIndex = 1;
                    Label lblDayEmployee = mvDay.FindControl("lblDayEmployee") as Label;
                    lblDayEmployee.Text = data.DayEmployee;
                    Label lblDayMobile = mvDay.FindControl("lblDayMobile") as Label;
                    lblDayMobile.Text = data.DayMobile;
                    Label lblNightEmployee = mvDay.FindControl("lblNightEmployee") as Label;
                    lblNightEmployee.Text = data.NightEmployee;
                    Label lblNightMobile = mvDay.FindControl("lblNightMobile") as Label;
                    lblNightMobile.Text = data.NightMobile;
                }
            }
        }
    }
      

  6.   

    12楼,千万别~俺结婚了,孩都快两岁了
    代码我也给你,你自己研究下先
    有问题再找我
    [email protected]