5月 17, 2010

捕捉新增事件


Sub EmployeeFormView_ItemInserted(ByVal sender As Object, ByVal e As FormViewInsertedEventArgs)
 
    ' Use the Exception property to determine whether an exception
    ' occurred during the insert operation.
    If e.Exception Is Nothing Then
   
      ' Use the AffectedRows property to determine whether the
      ' record was inserted. Sometimes an error might occur that
      ' does not raise an exception, but prevents the insert
      ' operation from completing.
      If e.AffectedRows = 1 Then
     
        MessageLabel.Text = "Record inserted successfully."
     
      Else
     
        MessageLabel.Text = "An error occurred during the insert operation."
       
        ' Use the KeepInInsertMode property to remain in insert mode
        ' when an error occurs during the insert operation.
        e.KeepInInsertMode = True
     
      End If
   
    Else
   
      ' Insert the code to handle the exception.
      MessageLabel.Text = e.Exception.Message
     
      ' Use the ExceptionHandled property to indicate that the
      ' exception has already been handled.
      e.ExceptionHandled = True
      e.KeepInInsertMode = True
   
    End If
       
  End Sub


5月 11, 2010

SQL 日期函數


SELECT DATEPART(year, GETDATE()) --抓年
SELECT DATEPART(month, GETDATE()) --抓月
SELECT DATEPART(day, GETDATE()) --抓日

DATEDIFF(Day, GETDATE(), 租期止日) AS 相差天數

CONVERT(varchar(12), getdate(), 111) 轉為 yy/mm/dd

CONVERT(varchar(12), getdate(), 105) 轉為 yy-mm-dd

其他:

select CONVERT(varchar, getdate(), 120 )
2004-09-12 11:06:08

select replace(replace(replace(CONVERT(varchar, getdate(), 120 ),'-',''),' ',''),':','')
20040912110608

select CONVERT(varchar(12) , getdate(), 111 )
2004/09/12

select CONVERT(varchar(12) , getdate(), 112 )
20040912

select CONVERT(varchar(12) , getdate(), 102 )
2004.09.12

select CONVERT(varchar(12) , getdate(), 101 )
09/12/2004

select CONVERT(varchar(12) , getdate(), 103 )
12/09/2004

select CONVERT(varchar(12) , getdate(), 104 )
12.09.2004

select CONVERT(varchar(12) , getdate(), 106 )
12 09 2004

select CONVERT(varchar(12) , getdate(), 107 )
09 12, 2004

select CONVERT(varchar(12) , getdate(), 108 )
11:06:08

select CONVERT(varchar(12) , getdate(), 109 )
09 12 2004 1

select CONVERT(varchar(12) , getdate(), 110 )
09-12-2004

select CONVERT(varchar(12) , getdate(), 113 )
12 09 2004 1

select CONVERT(varchar(12) , getdate(), 114 )
11:06:08.177

4月 17, 2010

斷行法


<%# "<br/>"+Eval("留言內容").ToString.Replace(Chr(10), "<br />") %>

4月 01, 2010

滑鼠右鍵選單

執行 SendTo

gridview的連動式下拉選單


protected void ddlDepNum_1Level_DataBound(object sender, EventArgs e)

    {


        DropDownList ddl_tmp_dep = ((DropDownList)sender); //上層 部門資料


        DropDownList ddl_tmp_emp = ((DropDownList)sender).NamingContainer.FindControl("ddl_emp") as DropDownList; //下層 部門員工資料


        SqlDataSource SqlDataSource_emp = ((DropDownList)sender).NamingContainer.FindControl("sdsEmpNum") as SqlDataSource; //下層的datasource


        SqlDataSource_emp.SelectParameters["Dept"].DefaultValue = ddl_tmp_dep.SelectedValue; //上層的部門代碼參數


        ddl_tmp_emp.DataBind();


    }


 


 


ddlDepNum_1Level_SelectedIndexChanged() 事件也一併使用