1. <ul id="0c1fb"></ul>

      <noscript id="0c1fb"><video id="0c1fb"></video></noscript>
      <noscript id="0c1fb"><listing id="0c1fb"><thead id="0c1fb"></thead></listing></noscript>

      99热在线精品一区二区三区_国产伦精品一区二区三区女破破_亚洲一区二区三区无码_精品国产欧美日韩另类一区

      RELATEED CONSULTING
      相關(guān)咨詢
      選擇下列產(chǎn)品馬上在線溝通
      服務(wù)時間:8:30-17:00
      你可能遇到了下面的問題
      關(guān)閉右側(cè)工具欄

      新聞中心

      這里有您想知道的互聯(lián)網(wǎng)營銷解決方案
      ASP.NETEval如何進行數(shù)據(jù)綁定-創(chuàng)新互聯(lián)

      這篇文章主要介紹“ASP.NET Eval如何進行數(shù)據(jù)綁定”,在日常操作中,相信很多人在ASP.NET Eval如何進行數(shù)據(jù)綁定問題上存在疑惑,小編查閱了各式資料,整理出簡單好用的操作方法,希望對大家解答”ASP.NET Eval如何進行數(shù)據(jù)綁定”的疑惑有所幫助!接下來,請跟著小編一起來學(xué)習(xí)吧!

      創(chuàng)新互聯(lián)建站是一群有想法、有熱情,對互聯(lián)網(wǎng)抱有執(zhí)著信念的年輕人,愿用自己的智慧和熱情,幫助您使用好互聯(lián)網(wǎng)工具,成為您的建站英雄,成為您網(wǎng)站制作和網(wǎng)絡(luò)營銷的“秘密武器”,專注于網(wǎng)站策劃、備案、主機域名、設(shè)計、后臺開發(fā)、關(guān)鍵詞優(yōu)化排名、運營管理、維護服務(wù)、微信網(wǎng)站、手機網(wǎng)站制作,網(wǎng)站上線不是大家合作的終結(jié),相反,網(wǎng)站維護才剛剛開始,我們期待常年累月的網(wǎng)站運行過程總著為您提供更多的支持。我們致力于解決問題,創(chuàng)造價值,不推諉,主動承擔(dān)。

      假設(shè)你已經(jīng)了解ASP.NET Eval 1.1的數(shù)據(jù)綁定(特別是Container這個局部變量)的機制,這里主要分析ASP.NET Eval 2.0數(shù)據(jù)綁定做了那些改進.

      ASP.NET Eval 2.0 的數(shù)據(jù)綁定函數(shù)Eval()簡化掉了ASP.NET Eval 1.1神秘的Container.DataItem,比如數(shù)據(jù)綁定表達式:


      復(fù)制代碼 代碼如下:


      <%# (Container.DataItem as DataRowView)["ProductName"].ToString() %>



      ASP.NET Eval 1.1簡化為:(去掉了類型指定, Eval通過反射實現(xiàn),本文不再闡述)


      復(fù)制代碼 代碼如下:


      <%# DataBinder.Eval(Container.DataItem, "ProductName").ToString() %>



      ASP.NET Eval 2.0又簡化為,去掉了Container局部變量:

      <%# Eval("ProductName") %>

      那么,Page.Eval()又是如何知道"ProductName"是那個數(shù)據(jù)的屬性呢,即Container.DataItem真的消失了嗎?

      ASP.NET Eval()是Page的父類TemplateControl的方法

      TemplateControl.Eval()可以自動計算出Container, 機制就是從一個dataBindingContext:Stack堆棧來獲取.

      1. 建立DataItem Container 棧:

      在Control.DataBind()中,建立,這樣可以保證子控件的DataItem Container始終在棧頂.


      復(fù)制代碼 代碼如下:


      public class Control

      {

      protected virtual void DataBind(bool raiseOnDataBinding)

      {

      bool foundDataItem = false; if (this.IsBindingContainer)

      {

      object o = DataBinder.GetDataItem(this, out foundDataItem);

      if (foundDataItem)

      Page.PushDataItemContext(o); <-- 將DataItem壓入堆棧

      }

      try

      {

      if (raiseOnDataBinding)

      OnDataBinding(EventArgs.Empty);

      DataBindChildren(); <-- 綁定子控件

      }

      finally

      {

      if (foundDataItem)

      Page.PopDataItemContext(); <-- 將DataItem彈出堆棧

      }

      }

      }

      2. 獲取DataItem Container


      復(fù)制代碼 代碼如下:


      public class Page

      {

      public object GetDataItem()

      {

      ...

      return this._dataBindingContext.Peek(); <-- 讀取堆棧頂部的DataItem Container,就是正在綁定的DataItem Container

      }

      }

      3. TemplateControl.Eval()


      復(fù)制代碼 代碼如下:


      public class TemplateControl

      {

      protected string Eval (string expression, string format)

      {

      return DataBinder.Eval (Page.GetDataItem(), expression, format);

      }

      }

      結(jié)論:

      從上面看出Page.Eval()在計算的時候還是引用了Container.DataItem,只不過這個DataItem通過DataItem Container堆棧自動計算出來的.我認為Page.Eval()看似把問題簡化了,其實把問題搞得更加神秘.

      到此,關(guān)于“ASP.NET Eval如何進行數(shù)據(jù)綁定”的學(xué)習(xí)就結(jié)束了,希望能夠解決大家的疑惑。理論與實踐的搭配能更好的幫助大家學(xué)習(xí),快去試試吧!若想繼續(xù)學(xué)習(xí)更多相關(guān)知識,請繼續(xù)關(guān)注創(chuàng)新互聯(lián)網(wǎng)站,小編會繼續(xù)努力為大家?guī)砀鄬嵱玫奈恼拢?/p>
      當(dāng)前標(biāo)題:ASP.NETEval如何進行數(shù)據(jù)綁定-創(chuàng)新互聯(lián)
      文章來源:http://www.ef60e0e.cn/article/epeep.html

      99热在线精品一区二区三区_国产伦精品一区二区三区女破破_亚洲一区二区三区无码_精品国产欧美日韩另类一区
      1. <ul id="0c1fb"></ul>

        <noscript id="0c1fb"><video id="0c1fb"></video></noscript>
        <noscript id="0c1fb"><listing id="0c1fb"><thead id="0c1fb"></thead></listing></noscript>

        阿鲁科尔沁旗| 洪洞县| 无棣县| 铅山县| 房产| 罗田县| 桑日县| 万全县| 吉林省| 专栏| 西盟| 景宁| 耒阳市| 大庆市| 东兴市| 封开县| 探索| 资源县| 大连市| 古田县| 上高县| 长沙市| 兴和县| 南木林县| 西和县| 大足县| 沈阳市| 津市市| 仪征市| 正宁县| 沁源县| 九龙县| 津市市| 安吉县| 绩溪县| 呈贡县| 股票| 武平县| 满城县| 雅江县| 开封市|