本文整理匯總了C#中System.Data.DataTable.ToShortDateString方法的典型用法代碼示例。如果您正苦於以下問題:C# DataTable.ToShortDateString方法的具體用法?C# DataTable.ToShortDateString怎麽用?C# DataTable.ToShortDateString使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類System.Data.DataTable
的用法示例。
在下文中一共展示了DataTable.ToShortDateString方法的3個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的C#代碼示例。
示例1: cbMonth_SelectedIndexChanged
private void cbMonth_SelectedIndexChanged(object sender, EventArgs e)
{
int month = (cbMonth.SelectedItem as ComboboxItem).Value.ToInt();
if (cbMonth.SelectedIndex != 0)
{
startDate = new DateTime(startDate.Year, month, 1, 1, 0, 0, 0);
endDate = new DateTime(endDate.Year, month, DateTime.DaysInMonth(endDate.Year, month), 23, 59, 59);
DateTimeFormatInfo dfi = DateTimeFormatInfo.CurrentInfo;
Calendar cal = dfi.Calendar;
if (startDate.DayOfWeek != DayOfWeek.Monday) { startDate = startDate.AddDays(7); }
DateTime dt = startDate;
if (cbWeek.Items.Count == 0)
{
cbWeek.Items.Add(new ComboboxItem { Text = "กรุณาเลือกสัปดาห์...", Value = 0 });
DayOfWeek startOfWeek = DayOfWeek.Monday;
int diff = dt.DayOfWeek - startOfWeek;
if (diff < 0)
{
diff += 7;
}
dt = dt.AddDays(-1 * diff).Date;
for (int i = 1; i <= 4; i++)
{
cbWeek.Items.Add(new ComboboxItem { Text = "ตั้งแต่ " + dt.ToShortDateString() + " ถึง " + dt.AddDays(6).ToShortDateString() , Value = dt.Day });
dt = dt.AddDays(7);
}
cbWeek.SelectedIndex = 0;
}
else
{
cbWeek.Items.Clear();
cbWeek.Items.Add(new ComboboxItem { Text = "กรุณาเลือกสัปดาห์...", Value = 0 });
DayOfWeek startOfWeek = DayOfWeek.Monday;
int diff = dt.DayOfWeek - startOfWeek;
if (diff < 0)
{
diff += 7;
}
dt = dt.AddDays(-1 * diff).Date;
for (int i = 1; i <= 4; i++)
{
cbWeek.Items.Add(new ComboboxItem { Text = "ตั้งแต่ " + dt.ToShortDateString() + " ถึง " + dt.AddDays(6).ToShortDateString(), Value = dt.Day });
dt = dt.AddDays(7);
}
cbWeek.SelectedIndex = 0;
}
}
}
示例2: Calendar_program_SelectionChanged
protected void Calendar_program_SelectionChanged(object sender, EventArgs e)
{
DateTime dt = Calendar_program.SelectedDate;
while (dt.DayOfWeek != DayOfWeek.Monday) dt = dt.AddDays(-1);
Label_program_dag.Text = dt.ToShortDateString() + " - ";
Label_program_sidste_dag.Text = dt.AddDays(6).ToShortDateString();
Repeater_program_dag.DataSource = program_dag(dt, dt.AddDays(6));
Repeater_program_dag.DataBind();
}
示例3: Page_Load
protected void Page_Load(object sender, EventArgs e)
{
DateTime dt = DateTime.Now;
while(dt.DayOfWeek != DayOfWeek.Monday) dt = dt.AddDays(-1);
Conn = new SqlConnection(ConfigurationManager.ConnectionStrings["ConnectionString"].ToString());
Label_program_dag.Text = dt.ToShortDateString() + " - ";
Label_program_sidste_dag.Text = dt.AddDays(6).ToShortDateString();
Repeater_program_dag.DataSource = program_dag(dt, dt.AddDays(6));
Repeater_program_dag.DataBind();
Calendar_program.SelectionMode = CalendarSelectionMode.DayWeek;
}