2010-06-13 86 views

回答

0

基本上有:

<%= this.YourPagesPublicProperty%> 

例如,我的ASP.NET文件:

<p>IntDicIsEmptyValue: <%= this.IntDicIsEmptyValue %></p> 
<asp:ListView ID="ListView1" runat="server" > 
    <LayoutTemplate> 
     <ul runat="server" id="itemPlaceholder"></ul>  
    </LayoutTemplate> 
    <ItemTemplate> 
     <p><%# Eval("Key") %>/<%# Eval("Value") %></p> 
    </ItemTemplate> 
    <EmptyDataTemplate> 
     <p>Status: <%= this.IntDicIsEmptyValue%></p> 
    </EmptyDataTemplate> 
</asp:ListView> 

我的cs文件:

public Dictionary<int,string> intdic; 
public string IntDicIsEmptyValue { get; set; } 


protected void Page_Load(object sender, EventArgs e) 
{ 
    IntDicIsEmptyValue = "Is Empty"; 
    intdic = new Dictionary<int, string>(); 
    //Comment next two lines to see Emptydatatemplate with IsEmpty 
    intdic.Add(3, "Three"); 
    intdic.Add(4, "Four"); 

    ListView1.DataSource = intdic; 
    ListView1.DataBind(); 

} 
+0

愚蠢的問題,回答它自己,,,使用頁面加載變量公共/私人頁 嘿嘿...謝謝 – eugeneK 2010-06-13 14:56:38

+0

剛剛編輯我的例子,是不是很好 – kamahl 2010-06-13 15:01:16