Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

ASP.NET ListView DataSource is string[]

Usually I would do this to display the data:

<%# Eval("string") %> This would work if the datasource was not an array of type string. Since there is no expression for the Eval method. How should I display the data?

aspx

        <ItemTemplate>
            <%# Eval("") %>
        </ItemTemplate>

codebehind:

    string[] images = Directory.GetFiles(UploadsPath);
    lvSlideShow.DataSource = images;
    lvSlideShow.DataBind();
like image 946
user1027620 Avatar asked Jun 19 '26 11:06

user1027620


1 Answers

Just use Container.DataItem. It is pointing at the current thing in the IEnumerable object being bound to.:

<ItemTemplate>
    <%# Container.DataItem %>
</ItemTemplate>
like image 82
Oleks Avatar answered Jun 20 '26 23:06

Oleks



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!