using System;
using System.Data;
using System.Configuration;
using System.Collections;
using System.Web;
using System;
using System.Data;
using System.Configuration;
using System.Collections;
using System.Web;
1.使用連接到資料庫,然後查詢要顯示的日期。
2.需有資料表 Holidays 的 SQL Server 資料庫。這個資料表具有資料行 HolidayDate。
3.連接到資料庫所需的連接字串 (Connection String) 則儲存在web.config檔的名稱ConnectionString1之下。
4.需匯入命名空間 (Namespace) System.Data 和 System.Data.SqlClient。
//將OnDayRender屬性加入至 Calendar 控制項標記,以使用DayRender事件。程式碼如下:
protected void GridView1_SelectedIndexChanged(object sender, EventArgs e)
{
Label1.Text = "第一個主索引鍵 = " & GridView1.SelectedDataKey.Values[0]. ToString();
Label2.Text = "第二個主索引鍵 = " & GridView1.SelectedDataKey.Values[1]. ToString();
Label3.Text = "GridView1.SelectedValue 主索引鍵 = " & GridView1.SelectedValue.ToString();
方式一:可手動在web.config下新增
方式二:在設計界面拉個SqlDataSource並連結完成
<connectionStrings>
<addname="Connection1"connectionString="Data Source=資料庫主機名稱與位址;Initial Catalog=資料庫名稱;Persist
Security Info=True;User ID=帳號;Password=密碼"providerName="System.Data.SqlClient"/>
http://www.connectionstrings.com/
收集各種 Connection String 的寫法,包含資料庫連線:SQL Server 2005、Sybase、Orcale、MySQL 等;資料檔案:Excel、Acess、SQLite...等‧
var count = 0;
//檢查輸入的字長度是否有超過280,若是中文字就自動算2個字元,數字及英文算1個字元
for(i=0;i<document.getElementById("MasterPage_MasterPageContent_odmhr07atextarea2_txt").value.length;i++)
{
if((document.getElementById("MasterPage_MasterPageContent_textarea2_txt").value.charAt(i).match(/[^a-z]/gi)) && (document.getElementById("MasterPage_MasterPageContent_textarea2_txt").value.charAt(i).match(/[^0-9]/g)))
JavaScript實作日期相減
//interval:必要項。用做為 Date1 和 Date2 間差值單位之時間間隔的 DateInterval 列舉值或 String 運算式。
Date.prototype.dateDiff = function(interval,objDate){
var dtEnd = new Date(objDate);
if(isNaN(dtEnd)) return undefined;