302班

          java突擊隊
          posts - 151, comments - 74, trackbacks - 0, articles - 14
            BlogJava :: 首頁 :: 新隨筆 :: 聯系 :: 聚合  :: 管理

          DataBinder.Eval用法范例

          Posted on 2007-04-10 13:49 停留的風 閱讀(1049) 評論(0)  編輯  收藏

          DataBinder.Eval用法范例

          常見綁定格式,不過他們的性能有區別。
          <%# DataBinder.Eval(Container.DataItem, "[n]") %>

          <%# DataBinder.Eval(Container.DataItem, "ColumnName") %>
          <%# DataBinder.Eval(Container.DataItem, "ColumnName", null) %>
          <%# DataBinder.Eval(Container, "DataItem.ColumnName", null) %>

          <%# ((DataRowView)Container.DataItem)["ColumnName"] %>
          <%# ((DataRowView)Container.DataItem).Row["ColumnName"] %>
          <%# ((DataRowView)Container.DataItem)["adtitle"] %>
          <%# ((DataRowView)Container.DataItem)[n] %>
          <%# ((DbDataRecord)Container.DataItem)[0] %>
          <%# (((自定義類型)Container.DataItem)).屬性.ToString() %>(如果屬性為字符串類型就不用ToString()了)
          上面這三個性能最好。
          //顯示二位小數
          //<%# DataBinder.Eval(Container.DataItem, "UnitPrice", "${0:F2}") %>  

          //{0:G}代表顯示True或False
          //<ItemTemplate>
          //     <asp:Image Width="12" Height="12" Border="0" runat="server"
          //            AlternateText='<%# DataBinder.Eval(Container.DataItem, "Discontinued", "{0:G}") %>'
          //            ImageUrl='<%# DataBinder.Eval(Container.DataItem, "Discontinued", "~/images/{0:G}.gif") %>' />
          // </ItemTemplate>

          //轉換類型
           ((string)DataBinder.Eval(Container, "DataItem.P_SHIP_TIME_SBM8")).Substring(4,4)

          {0:d} 日期只顯示年月日
          {0:yyyy-mm-dd} 按格式顯示年月日
          {0:c} 貨幣樣式

          只有注冊用戶登錄后才能發表評論。


          網站導航:
           
          主站蜘蛛池模板: 彭阳县| 丹东市| 中山市| 湘潭市| 红桥区| 南澳县| 波密县| 西青区| 新宾| 绿春县| 凌云县| 郴州市| 海安县| 石屏县| 资溪县| 杭锦后旗| 兰州市| 怀远县| 德令哈市| 大足县| 呼伦贝尔市| 射阳县| 会理县| 和田市| 文安县| 房产| 绥芬河市| 理塘县| 西昌市| 兴仁县| 赤水市| 赫章县| 慈利县| 内乡县| 上栗县| 临江市| 石家庄市| 疏勒县| 慈利县| 鄱阳县| 清河县|