Cannot convert type 'Microsoft.SharePoint.WebControls.SPSqlDataSource' to 'System.Web.UI.IAttributeAccessor' - SharePoint 2010 開發

  • 2797
  • 0

在 SharePoint ASPX 頁面進行 Code-Behind 模式開發時, 原來用 DataFormWebPart Layout的頁面, 出現錯誤訊息...

在 SharePoint ASPX 頁面進行 Code-Behind 模式開發時, 原來用 DataFormWebPart Layout的頁面, 出現下列訊息

Cannot convert type 'Microsoft.SharePoint.WebControls.SPSqlDataSource' to 'System.Web.UI.IAttributeAccessor'

image

原因是因為 DataFormWebPart Layout 下,

預設會再 SqlDataSource 控制項產生屬性 __designer:customcommand="true"

image

而在原  System.Web.UI.WebControls  並無該屬性

將改屬性刪除後, 即可於 Code-Behind 模式下正常開發…