ASP.NET 學習5_資料綁定的方式

ASP.NET 2.0 的Data-Binding 資料繫結(綁定)語法表示語法:
<%# Data Source Name %>
當中可以是Single Value Data Binding也可以是Repeated Value Data Binding

Single Value Data Binding常見使用情境:
<%# Name of the Property %>
<%# Expression %>
<%# Method Name, Parameter List %>


Repeated Value Data Binding常見使用情境:
<%# Name of the Data Source %>

在當中要填入的是
於webform中的兩種綁定語句
單向綁定(唯讀):Eval
>如資料只需要呈現則適用此方式
雙向綁定(可讀寫,有Insert、Update、Delete):Bind
>如資料需要編輯更新則適用此方式

 
如維護到舊時期有歷史包袱的專案看到此語法
<%# Container.DataItem("expression") %>
則是ASP.NET 1.0時期的產物,效能比較沒這麼好(因屬於晚期繫結 (Late Binding))。
<%# DataBinder.Eval(Container.DataItem,”fieldName”) %>






Ref:
http://www.blueshop.com.tw/board/FUM20041006161839LRJ/BRD20071025101635BBI.html
https://docs.microsoft.com/zh-tw/dotnet/api/system.web.ui.databinder?view=netframework-4.8
https://dotblogs.com.tw/jeff-yeh/2009/12/14/12446
https://kingjoy1235.pixnet.net/blog/post/32864032
https://dotblogs.com.tw/regionbbs/2016/10/13/concepts-in-late-binding

留言

這個網誌中的熱門文章

經得起原始碼資安弱點掃描的程式設計習慣培養(五)_Missing HSTS Header

經得起原始碼資安弱點掃描的程式設計習慣培養(三)_7.Cross Site Scripting(XSS)_Stored XSS_Reflected XSS All Clients

(2021年度)駕訓學科筆試準備題庫歸納分析_法規是非題