婷婷综合国产,91蜜桃婷婷狠狠久久综合9色 ,九九九九九精品,国产综合av

主頁 > 知識(shí)庫 > ASP.NET數(shù)據(jù)綁定的記憶碎片實(shí)現(xiàn)代碼

ASP.NET數(shù)據(jù)綁定的記憶碎片實(shí)現(xiàn)代碼

熱門標(biāo)簽:東莞語音電銷機(jī)器人排名 朝陽市地圖標(biāo)注 使用智能電話機(jī)器人違法嗎 太原外呼電銷機(jī)器人費(fèi)用 外呼系統(tǒng)用員工身份證 淘寶地圖標(biāo)注如何做 蘇州銷售外呼系統(tǒng)預(yù)算 保山電話外呼管理系統(tǒng)怎么用 電話機(jī)器人廣告話術(shù)
ASP.NET數(shù)據(jù)綁定的一般情況

1、%= C#代碼 %> //調(diào)用代碼隱藏頁面的方法、屬性、或者字段
這里一般是調(diào)用屬性和方法比較多,要注意調(diào)用的屬性、方法或者字段的作用域,必須是可以在ASPX頁面可以訪問到的。

代碼示例(ASPX):%=Property%>

在(CS)是: public string Property{ get { return "This is a Property";} }
屬性是這樣使用的,方法和字段的使用類似,也是這樣實(shí)現(xiàn)的。

2、%#數(shù)據(jù)綁定表達(dá)式%>//是在列表控件里面使用的

使用方式一:%# Eval("FirstName")%>
使用方式二:%# DataBinder.Eval(Container.DataItem, "SecondName")%>
下面附上我調(diào)試的源碼,可以復(fù)制過去看看

在ASPX頁面:

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

%@ Page Language="C#" AutoEventWireup="true" CodeBehind="Default.aspx.cs" Inherits="DataBindEx._Default" %>
%@ Import Namespace="System.Data" %>
%@ Import Namespace="System.Collections.Generic" %>
!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
html xmlns="http://www.w3.org/1999/xhtml">
head runat="server">
title>/title>
/head>
body>
form runat="server">
div>
%=Property%>
br />
asp:TextBox ID="TextBox1" Text="This is TextBox of serverClient " runat="server">/asp:TextBox>
br />
%=Method()%>
br />
br />
asp:Label ID="Label1" runat="server">%=TextBox1.Text %>/asp:Label>
br />
%=(Property + " " + Method())%>
/div>
div>
asp:Repeater ID="Repeater1" runat="server" OnItemDataBound="RptAllOnItemDataBound">
HeaderTemplate>
This is Headerbr />
/HeaderTemplate>
ItemTemplate>
FirstName:%# Eval("FirstName")%>
SecondName:%# DataBinder.Eval(Container.DataItem, "SecondName")%>
FullName:%# (Container.DataItem as DataBindEx.Person).FullName%>
asp:Literal ID="Others" runat="server">/asp:Literal>
br />
/ItemTemplate>
FooterTemplate>
This is footerbr />
/FooterTemplate>
/asp:Repeater>
/div>
/form>
/body>
/html>

在CS頁面:
復(fù)制代碼 代碼如下:


using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.MobileControls;
namespace DataBindEx
{
public class Person
{
public string FirstName
{
get;
set;
}
public string SecondName
{
get;
set;
}
public string FullName
{
get
{
return FirstName + SecondName;
}
}
}
public partial class _Default : System.Web.UI.Page
{
public string Property
{
get
{
return "This is a Property";
}
}
protected void Page_Load(object sender, EventArgs e)
{
string str = TextBox1.Text;
Person per = new Person();
per.FirstName= "劉";
per.SecondName= "明豐";
Person per1 = new Person();
per1.FirstName = "林";
per1.SecondName = "旺";
Person per2 = new Person();
per2.FirstName = "陳";
per2.SecondName = "仁峰";
ListPerson> list = new ListPerson>();
list.Add(per);
list.Add(per1);
list.Add(per2);
Repeater1.DataSource = list;
Repeater1.DataBind();
}
protected void RptAllOnItemDataBound(object sender, RepeaterItemEventArgs e)
{
Person pe = (Person)e.Item.DataItem;
Literal lit = e.Item.FindControl("Others") as Literal;
if (pe !=null)
switch (pe.FirstName)
{
case "劉":
lit.Text = "劉喜歡打球";
break;
case "林":
lit.Text = "林喜歡下棋";
break;
default:
lit.Text = "陳喜歡c#";
break;
}
}
protected string Method()
{
return "This is a Method";
}
}
}
您可能感興趣的文章:
  • asp.net數(shù)據(jù)綁定時(shí)動(dòng)態(tài)改變值的代碼
  • 淺析DataBinder.Eval和Eval的區(qū)別
  • 深入理解Asp.net中DataBinder.Eval的用法總結(jié)
  • asp.net數(shù)據(jù)綁定DataBind使用方法

標(biāo)簽:阿里 洛陽 西藏 運(yùn)城 呼倫貝爾 綏化 潛江 克拉瑪依

巨人網(wǎng)絡(luò)通訊聲明:本文標(biāo)題《ASP.NET數(shù)據(jù)綁定的記憶碎片實(shí)現(xiàn)代碼》,本文關(guān)鍵詞  ASP.NET,數(shù)據(jù),綁,定的,記憶,;如發(fā)現(xiàn)本文內(nèi)容存在版權(quán)問題,煩請(qǐng)?zhí)峁┫嚓P(guān)信息告之我們,我們將及時(shí)溝通與處理。本站內(nèi)容系統(tǒng)采集于網(wǎng)絡(luò),涉及言論、版權(quán)與本站無關(guān)。
  • 相關(guān)文章
  • 下面列出與本文章《ASP.NET數(shù)據(jù)綁定的記憶碎片實(shí)現(xiàn)代碼》相關(guān)的同類信息!
  • 本頁收集關(guān)于ASP.NET數(shù)據(jù)綁定的記憶碎片實(shí)現(xiàn)代碼的相關(guān)信息資訊供網(wǎng)民參考!
  • 推薦文章
    主站蜘蛛池模板: 什邡市| 铜鼓县| 蓝山县| 山西省| 黄浦区| 五寨县| 施秉县| 鄂托克前旗| 柳江县| 西贡区| 宝应县| 清丰县| 渝北区| 奉贤区| 会宁县| 陵水| 康保县| 乌拉特中旗| 三门峡市| 樟树市| 嘉禾县| 阿荣旗| 长垣县| 绥滨县| 台中县| 昌宁县| 通榆县| 南陵县| 龙井市| 桦甸市| 太保市| 双柏县| 赣榆县| 嘉定区| 吴川市| 湟中县| 连山| 息烽县| 长阳| 林芝县| 益阳市|