开发者

ASP.NET is it possible to access public page variables from ListView.EmptyDataTemplate?

开发者 https://www.devze.com 2023-01-03 02:47 出处:网络
is it 开发者_如何学Cpossible to access public page variables from ListView.EmptyDataTemplate ? Can i do that and if can, how ?

is it 开发者_如何学Cpossible to access public page variables from ListView.EmptyDataTemplate ?

Can i do that and if can, how ?

thanks


Basically with:

 <%= this.YourPagesPublicProperty%>

Example, my ASP.NET File:

<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>

And my .cs File:

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

精彩评论

暂无评论...
验证码 换一张
取 消