views:

37

answers:

1

Hi

i am a bit confused on how to display all the items in session in a repeater

Any suggestion??

+2  A: 

HttpSessionState implements IEnumerable, so you can bind directly to that.

// Code-behind
this.Repeater1.DataSource = Session;
this.Repeater1.DataBind();

The session enumerates its keys, not its values, so if you want to see both, do this in your .aspx template:

<asp:Repeater runat="server" ID="Repeater1">
    <ItemTemplate>
        Key: <%# Container.DataItem %>,
        Value: <%# Session[Container.DataItem.ToString()].ToString() %>
    </ItemTemplate>
</asp:Repeater>
Jeff Sternal