版權(quán)說明:本文檔由用戶提供并上傳,收益歸屬內(nèi)容提供方,若內(nèi)容存在侵權(quán),請進行舉報或認領(lǐng)
文檔簡介
1、<p><b> 附 錄1英文原文</b></p><p> The Data Binding Technology</p><p> In my project,I need to show the data from the DataBase,so I need to use the data binding technology which Mi
2、crosoft company support.In the following ,let's discuss it together.</p><p> If you are familiar with classic ASP, the declarative data binding syntax introduced in ASP.NET will be familiar to you even
3、though the functionality is vastly different. Data binding expressions are the code you see between <%# and %> characters in an ASPX file. The expressions allow you to easily bind controls to data sources, as well
4、as properties, expressions, and results from method calls exposed by the page. While this feature is easy to use, it often causes some confusion about what is al</p><p> Data binding basics</p><p
5、> Data binding expressions link ASP.NET page properties, server control properties, and data sources when the page's DataBind method is called. You can place data binding expressions on the value side of an attri
6、bute/value pair in the opening tag of a server control or anywhere in the page. All data binding expressions, regardless of where you place them, must be contained between <%# and %> characters.</p><p>
7、; When used with data controls (like Repeater, DataGrid, and so forth), the expression parameter is usually a column name from the data source. However, as long as it returns a value, any valid expression may be used. L
8、ikewise, the same syntax may be used outside list controls. This includes displaying values on the page or populating control attributes.</p><p> Container.DataItem is a runtime alias for the DataItem bound
9、 to a specific item. It maps to an individual item from the data source like one row from a database query or an individual element from an array. The actual data type for the DataItem is determined by the data source. S
10、o, if you're dealing with an array of integers, the DataItem will be an integer.</p><p> The following list provides a quick review of the VB.NET syntax for various scenarios:</p><p> <
11、%# Container.DataItem %>--An array of string values is returned. </p><p> <%# Container.DataItem("expression") %>--The specific field from a DataView container is returned. </p>&l
12、t;p> <%# Container.DataItem.PropertyName %>--The specific string property value of data source is returned. </p><p> <%# CStr(Container.DataItem.PropertyName) %>--Returns a property value co
13、nverted to its string representation. </p><p> When you're using C#, the syntax is a bit different. The following list includes the corresponding C# code for each line in the previous list. Notice the b
14、asic syntax is the same, but it changes when property values are returned and converted to the appropriate data type.</p><p> <%# Container.DataItem %> </p><p> <%# ((DataRowView)Cont
15、ainer.DataItem)["PropertyName"] %> </p><p> <%# ((ObjectType)Container.DataItem).PropertyName %> </p><p> <%# ((ObjectType)Container.DataItem).PropertyName.ToString() %&g
16、t; </p><p> Syntax is consistent when working with page level properties and methods. The syntax remains the same as long as string values are returned. The following list provides some examples:</p>
17、<p> <%# propertyName %>--The value for a page level property is returned. </p><p> <asp:ListBox id="lstValues" datasource='<%# propertyName %>' runat="server&qu
18、ot;>--The value retrieved from the page level property (array, collection of objects, etc.) is bound to the data control. </p><p> <%# (objectName.PropertyName) %>--The value of the page level obje
19、ct property is displayed. </p><p> <%# MethodName() %>--The value returned from the page method is displayed. </p><p> You may use individual values (albeit properties, method return val
20、ues, and so forth) on a page using the following syntax:</p><p> <%= Value %></p><p> The C# code in Listing A demonstrates data binding in an ASP.NET Web form. It selects employee names
21、 and telephone numbers from the SQL Server Northwind Employees table. The values from the query are displayed via an ASP.NET Repeater control. The column values are inserted via data binding, and the form's window ti
22、tle is populated using a method call. In addition, the ItemIndex property of the DataItem is used to display a row number. The ItemIndex property begins with zero, so one is added befo</p><p> Listing B con
23、tains the equivalent VB.NET code. The main difference is the use of parentheses as opposed to brackets in C#. Also, the casting of the rows is not necessary with VB.NET.</p><p> Using the Contain.DataItem o
24、bject can be tedious, since you must be aware of the data type and convert it accordingly for use. Microsoft does provide the DataBinder class to further simplify development.</p><p> Microsoft documentatio
25、n (on MSDN) states the DataBinder class uses reflection to parse and evaluate a data binding expression against an object at runtime. This method allows RAD designers, such as Visual Studio .NET, to easily generate and p
26、arse data binding syntax. This method can also be used declaratively on a Web form's page to simplify casting from one type to another.</p><p> You can use the Eval method of the DataBinder class to mak
27、e .NET do the heavy lifting when using data values in an ASP.NET page. The Eval method accepts the previously covered Container.DataItem object; it works hard to figure out the details of the field identified in the expr
28、ession and displays it accordingly. It has the following syntax:</p><p> DataBinder.Eval(Container.DataItem, "field name", "optional formatting")</p><p> Using this syntax,
29、 you could rewrite the first example to use DataBinder.Eval to look like the C# code in Listing C. Listing D contains the equivalent VB.NET code.</p><p> The DataBinder.Eval approach is great as it pushes w
30、ork to the system. On the other hand, you should use it with caution, since time and resources are consumed as the system locates the element and determines its object/data type.</p><p> Plenty of options&l
31、t;/p><p> Data binding makes it relatively simple to include data in ASP.NET pages. There are various data binding options available, which include: binding the data to a control and allowing it to decide how
32、it is presented, or choosing declarative data binding to control presentation within the ASP.NET page. In the end, it comes down to your preference, but it is great to have options.</p><p><b> 附 錄2中文譯
33、文</b></p><p><b> 數(shù)據(jù)捆綁技術(shù)</b></p><p> 在我的項目中,我需要從數(shù)據(jù)庫顯示數(shù)據(jù),因此我使用數(shù)據(jù)捆綁的技術(shù) 它是由微軟公司支持的。如下,我們一起來談?wù)撍?lt;/p><p> 如果你熟悉經(jīng)典ASP,在ASP.NET介紹申明數(shù)據(jù)捆綁的句法與它在功能是有很大的不同。 數(shù)據(jù)捆綁的表達方式:就是能在AS
34、PX文件中以在此形式(< %#和% >)之間出現(xiàn)的代碼。 這種表達方式允許你把控件很容易地綁定到數(shù)據(jù)源,連同屬性,語法,結(jié)果值同時在方法調(diào)用時在頁面中顯示。 當(dāng)這些特性輕松的被使用時,由于它是否被允許能夠被調(diào)用而經(jīng)常造成一些的混亂。</p><p> 數(shù)據(jù)捆綁的基本原則:</p><p> 當(dāng)DataBind方法被調(diào)用時,數(shù)據(jù)就捆綁到ASP.NET的控件屬性,數(shù)據(jù)源。 數(shù)據(jù)
35、表達式可以放置在頁面的任何一處,或置于服務(wù)器控件成對標簽的之間的附值處。 所有數(shù)據(jù)捆綁的表達式,不論是將它們放置在哪,都必須包含在< %#和% >標志之間。</p><p> 當(dāng)數(shù)據(jù)控件(像轉(zhuǎn)發(fā)器一樣,DataGrid,如此等等)綁定時,表達參數(shù)通常是數(shù)據(jù)源的一張表的一個列名。盡管如此,只要返回一個數(shù)值,這個數(shù)值表達式就被調(diào)用了。 同樣地,相同的句法可以用在列表控件之外。 這主要包括在頁面上顯示數(shù)值
36、或者是控件的屬性值。</p><p> Container.DataItem是專門為DataItem綁定到特殊項上專門設(shè)置的控件。它指向數(shù)據(jù)源處的一個數(shù)據(jù)項目如表中的一個數(shù)據(jù)行或者是列表中的某個元素的值。 DataItem的實際的數(shù)據(jù)類型是由數(shù)據(jù)源確定的。 因此,如果你處理一個整型數(shù)組,DataItem的數(shù)據(jù)類型則是整型。</p><p> 下面的表達式是用VB.Net來調(diào)用在各種情況
37、下Container.DataItem的調(diào)用情況,讓我們來快速的回顧下。</p><p> < %# Container.DataItem % > --串價值的一個陣列被返回。 </p><p> < %# Container.DataItem (“表達”) % > --從一個DataView容器的具體的值被返回。 </p><p>
38、< %# Container.DataItem.PropertyName % > --數(shù)據(jù)源的具體的串值被返回。 </p><p> < %# CStr ( Container.DataItem.PropertyName ) % > --用被改變的一數(shù)值覆蓋其串值表達式值。 </p><p> 當(dāng)你使用C#時,句法是有點不同的。 下列表達式則在原先的列基礎(chǔ)上每行
39、再加上相應(yīng)的C#代碼。 注意到基本的句法同樣,但是當(dāng)數(shù)值被返回和返回值被改變成為適當(dāng)?shù)臄?shù)據(jù)類型時,它就發(fā)生變化了。</p><p> < %# Container.DataItem % ></p><p> < %# ( ( DataRowView ) Container.DataItem )["PropertyName" ] % ><
40、/p><p> < %# ( ( ObjectType ) Container.DataItem ).PropertyName % ></p><p> < %# ( ( ObjectType ) Container.DataItem ).PropertyName.ToString ( ) % ></p><p> 句法是與當(dāng)頁面的屬性和方
41、法一致的被。當(dāng)串值被返回時,語法結(jié)構(gòu)仍然保持不變。 如下則是提供了一些例子:</p><p> < %# propertyName % > --一頁面屬性值被返回。 </p><p> < asp:ListBox id="lstValues”datasource='<%# propertyName %>的runat="serve
42、r" > --從頁面取回的數(shù)值(數(shù)組,對象集)綁定倒數(shù)據(jù)控件上。 </p><p> < %# ( objectName.PropertyName ) % > --頁實例屬性值被顯示。 </p><p> < %# MethodName( ) % > --調(diào)用方法時返回的值顯示。 </p><p> 你能在Page頁上使
43、用如下句法使用特殊的的數(shù)值( 屬性值,方法返回值,等等):</p><p><b> < %=數(shù)值% ></b></p><p> 在列表A中的C#代碼是用ASP.NET技術(shù)實現(xiàn)的數(shù)據(jù)捆綁。 它從SQL服務(wù)器Northwind雇員表中選擇雇員名稱和電話號碼。 查詢的數(shù)值是通過ASP.NET轉(zhuǎn)發(fā)器來控制顯示的。 列表數(shù)值通過數(shù)據(jù)捆綁的技術(shù)被插入,而For
44、m的頁面數(shù)值是通過使用方法調(diào)用來實現(xiàn)數(shù)值的傳遞。此外,DataItem的ItemIndex屬性用來顯示一數(shù)字。ItemIndex屬性從零開始,因此一但有數(shù)值顯示,它就自動的+1</p><p> 列表B包含相等的VB.NET代碼。 主要的區(qū)別在于在C#中應(yīng)用了括號。然而,這不是VB.NET的必須執(zhí)行的。</p><p> 當(dāng)意識到使用時必須知道數(shù)據(jù)類型并且要隨著應(yīng)用而發(fā)生改變時,就會覺
45、得使用Contain.DataItem變得有些麻煩,不是很方便。因此微軟對DataBinder類作了改進,使它的應(yīng)用變得相對要簡單些。</p><p> 在系統(tǒng)運行時,微軟文件(在MSDN上)申明在DataBinder類中將數(shù)據(jù)綁定表達式的值的數(shù)據(jù)類型強制轉(zhuǎn)換成實例的數(shù)值類型。在Visual Studio .NET中,這方法讓RAD設(shè)計者很容易對數(shù)據(jù)捆綁的句法作語法分析。 這方法也能通過申明將一個Web的頁面類
46、型很簡單的轉(zhuǎn)換成為另一種類型。</p><p> 當(dāng)在頁面中使用數(shù)據(jù)值時,DataBinder類的Eval方法能起著舉足輕重的作用。 Eval方法接受以前覆蓋的Container.DataItem對象; 它根據(jù)情況改變,根據(jù)表達式推算出字段的具體細節(jié)并且將它顯示出來。它有如下句法:</p><p> DataBinder.Eval ( Container.DataItem,“字段名”,
47、“格式化選項”)</p><p> 使用這種句法結(jié)構(gòu),列表C.列表D中看起來象C#代碼,就能像使用DataBinder.Eval重寫第一個包含相同結(jié)構(gòu)的VB.NET代碼例子。</p><p> DataBinder.Eval方法應(yīng)用到系統(tǒng)中時,功能是很強的。 但同時,當(dāng)時間和資源隨著系統(tǒng)調(diào)用元素項并決定調(diào)用返回數(shù)據(jù)類型而慢慢耗盡時,就必須謹慎的使用。</p><p&
溫馨提示
- 1. 本站所有資源如無特殊說明,都需要本地電腦安裝OFFICE2007和PDF閱讀器。圖紙軟件為CAD,CAXA,PROE,UG,SolidWorks等.壓縮文件請下載最新的WinRAR軟件解壓。
- 2. 本站的文檔不包含任何第三方提供的附件圖紙等,如果需要附件,請聯(lián)系上傳者。文件的所有權(quán)益歸上傳用戶所有。
- 3. 本站RAR壓縮包中若帶圖紙,網(wǎng)頁內(nèi)容里面會有圖紙預(yù)覽,若沒有圖紙預(yù)覽就沒有圖紙。
- 4. 未經(jīng)權(quán)益所有人同意不得將文件中的內(nèi)容挪作商業(yè)或盈利用途。
- 5. 眾賞文庫僅提供信息存儲空間,僅對用戶上傳內(nèi)容的表現(xiàn)方式做保護處理,對用戶上傳分享的文檔內(nèi)容本身不做任何修改或編輯,并不能對任何下載內(nèi)容負責(zé)。
- 6. 下載文件中如有侵權(quán)或不適當(dāng)內(nèi)容,請與我們聯(lián)系,我們立即糾正。
- 7. 本站不保證下載資源的準確性、安全性和完整性, 同時也不承擔(dān)用戶因使用這些下載資源對自己和他人造成任何形式的傷害或損失。
最新文檔
- 計算機專業(yè)外文翻譯---數(shù)據(jù)捆綁技術(shù)
- 外文翻譯---數(shù)據(jù)倉庫技術(shù)
- 特警捆綁技術(shù)
- 外文文獻翻譯---數(shù)據(jù)挖掘技術(shù)簡介
- 數(shù)據(jù)采集外文翻譯
- 數(shù)據(jù)設(shè)計外文翻譯
- 數(shù)據(jù)采集外文翻譯
- 數(shù)據(jù)加密外文翻譯
- 數(shù)據(jù)庫技術(shù)簡介畢業(yè)論文外文翻譯
- 外文翻譯---數(shù)據(jù)采集簡介
- [雙語翻譯]大數(shù)據(jù)外文翻譯--大數(shù)據(jù)中的數(shù)據(jù)學(xué)習(xí)
- 外文翻譯--數(shù)據(jù)結(jié)構(gòu)
- 外文翻譯--數(shù)據(jù)代碼生成
- 數(shù)據(jù)加密標準外文翻譯
- 外文翻譯-----數(shù)據(jù)挖掘什么是數(shù)據(jù)挖掘?
- 客戶關(guān)系管理中的數(shù)據(jù)挖掘技術(shù)【外文翻譯】
- 外文翻譯--制造分析進程數(shù)據(jù)使用快速標記技術(shù)
- [雙語翻譯]大數(shù)據(jù)外文翻譯--大數(shù)據(jù)中的數(shù)據(jù)學(xué)習(xí)(英文)
- 外文翻譯--制造分析進程數(shù)據(jù)使用快速標記技術(shù)
- 數(shù)據(jù)庫設(shè)計外文翻譯
評論
0/150
提交評論