2011-06-23 15 views
0

私はタイムトラッカーとして使用しているasp.netカレンダーを持っています。現在、私は必要な情報でカレンダーにデータを入力するmysqlクエリを持っていますが、日の1つが選択されたときにこの情報を取得する方法はわかりません。ユーザーが日付を選択すると、その日の情報を取得し、カップルのラベルを入力したいと考えています。カレンダーコードは次のとおりです。ありがとう。asp.netカレンダーのハイパーリンクの使用

 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 
+0

「日付から情報を取得する」とは、選択した日付自体を正確に意味しますか? – R3D3vil

+0

選択した日付と、その日付のツールチップに追加した情報をページのカップルのラベルに追加します。あるいは、日付がクリックされたときに、より簡単な場合は、mysqlに対してクエリを実行して、ラベルを設定します。 基本的に、日付がクリックされたときに何が起こっているのかわかりません!私はこのことを初めて知っています。 –

答えて

0

次のコードはC#で選択された日付とラベルを移入:

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

この日付に基づいてクエリを実行し、他の値を取得することができます。

+0

私はこの銃を飛ばしました。 maxselectioncountやselectionrangeの選択肢がありません。 私は正しい軌道にいると信じています: selecteddate = Calendar1.SelectedDate.ToString() query = "login = 'username'とWhere Date = '"&selecteddateのバケーションからの日付、 & "'" この問題は、dayrenderイベントでこれをやっているので、カレンダーが読み込まれる毎月の選択された日を通り抜けます。 –

関連する問題