使用asp.net日历中的超链接

时间:2011-06-23 15:30:48

标签: asp.net mysql calendar

我有一个asp.net日历,我正在使用它作为时间跟踪器。目前,我有一个mysql查询填充日历与所需的信息,但我不知道如何选择其中一天时检索此信息。当用户选择日期时,我想从日期中获取信息并填充几个标签。日历代码如下。感谢。

        If Not dsDate Is Nothing Then
        For Each dr As DataRow In dsDate.Tables(0).Rows
            description = CType(dr("Description"), String)
            nextDate = CType(dr("Date"), DateTime)
            hours = CType(dr("Hours"), Integer)
            If nextDate = e.Day.Date And description = "Sick" Then
                e.Cell.BackColor = System.Drawing.Color.DarkGreen
                e.Cell.ToolTip = description & " - " & hours & " Hours"
            ElseIf nextDate = e.Day.Date And description = "Vacation" Then
                e.Cell.BackColor = System.Drawing.Color.Brown
                e.Cell.ToolTip = description & " - " & hours & " Hours"
            End If
        Next
    End If
    If e.Day.IsWeekend Then
        e.Cell.BackColor = System.Drawing.Color.LightSkyBlue
        e.Day.IsSelectable = False
    End If
    If nottouched And Not e.Day.IsWeekend And Not e.Cell.BackColor = System.Drawing.Color.DarkGreen And Not e.Day.IsOtherMonth And Not e.Cell.BackColor = System.Drawing.Color.Brown Then
        e.Cell.Attributes.Add("onmouseover", onmouseoverStyle)
        e.Cell.Attributes.Add("onmouseout", onmouseoutStyle.Replace("@BackColor", rowBackColor))
    End If

1 个答案:

答案 0 :(得分:0)

以下代码使用在C#中选择的日期填充标签:

  

monthCalendar1.MaxSelectionCount = 1;
  label1.Text = monthCalendar1.SelectionRange.Start.ToShortDateString();

现在,您可以根据此日期运行查询,并尝试获取其他值。