FormatException未被用戶代碼處理。
該字符串未被識別爲有效的DateTime。DateTime無法識別
protected void Page_Load(object sender, EventArgs e)
{
// to simulate a database query
socialEvents = new DataTable();
socialEvents.Columns.Add(new DataColumn("Date", typeof(DateTime)));
socialEvents.Columns.Add(new DataColumn("Description", typeof(string)));
socialEvents.Columns.Add(new DataColumn("Url", typeof(string)));
DataRow row;
row = socialEvents.NewRow();
row["Date"] = DateTime.Now.AddDays(-5);
row["Description"] = "Work";
row["Url"] = "http://www.url.cz";
socialEvents.Rows.Add(row);
}
錯誤在以下梅索德:
protected void Calendar1_DayRender(object sender, DayRenderEventArgs e)
{
**DataRow[] rows = socialEvents.Select(
String.Format(
"Date >= #{0}# AND Date < #{1}#",
e.Day.Date.ToShortDateString(),
e.Day.Date.AddDays(1).ToShortDateString()**
)
);
工作正常,當我在我的系統上運行它,但我用datetime.now替換e.Day.Date – 1Mayur 2013-02-27 08:26:19
我也替換它,但它不工作 – 2013-02-27 08:29:58
你有什麼想法出了什麼問題? – 2013-02-27 08:34:48