对Datalist控件中的图片进行排序

发布于 2024-12-28 07:42:52 字数 1497 浏览 0 评论 0原文

我有一个数据列表控件并从文件夹中读取图片并将它们显示在数据列表的灯箱中我还从这些图片中读取数据和时间。第一件事是数据列表没有读取从属性中获取的日期图片,第二件事是图片未按拍摄日期的降序排序。请有人告诉我如何完成这些任务。 我的数据列表代码在这里

<asp:DataList ID="DataList1" runat="server" RepeatColumns="5" RepeatDirection="Horizontal" Width="23%" CellPadding="2" CellSpacing="0" Height="270px" HorizontalAlign="Center">

<ItemTemplate>
<asp:Image Width="200px" height="200px" ID="Image1" ImageUrl='<%# Bind("Name", "~/MMS/1 Box/{0}") %>' runat="server" />
<br />

<asp:HyperLink ID="HyperLink1" rel="lightbox[roadtrip]" title='<%# DataBinder.Eval(Container.DataItem, "LastWriteTime", "{0:yyyy-MM-dd   hh:mm:ss}") %>'
 Text="Zoom" NavigateUrl='<%# Bind("Name", "~/MMS/1 Box/{0}") %>' runat="server"/>
</ItemTemplate>
<ItemStyle BorderColor="Silver" BorderStyle="Dotted" BorderWidth="1px" HorizontalAlign="Center"

VerticalAlign="Bottom" />
</asp:DataList>

,从文件夹中读取图像我的 vb.net 代码在这里

Sub loadimage()
        Dim sdir As New DirectoryInfo(MapPath("~/MMS/1 Box"))

        Dim file As FileInfo() = sdir.GetFiles()
        Dim list As New ArrayList()

        For Each file2 As FileInfo In file
            If file2.Extension = ".jpg" OrElse file2.Extension = ".gif" OrElse file2.Extension = ".bmp" Then

                list.Add(file2)

            End If

        Next

        DataList1.DataSource = list

        DataList1.DataBind()


    End Sub

有人告诉我我应该在代码中进行哪些更改,以便我的两个要求也能完成

I Have a Datalist Control and Reading the pictures from folder and showing them in lightbox from Datalist i am also reading data and time from those pictures.Ist thing is that the datalist is not reading the Date picture taken from the attributes and second is that pictures are not being sorted in desc order of date picture taken.Please anyone tell me how can i complete these taskes.
My data list code is here

<asp:DataList ID="DataList1" runat="server" RepeatColumns="5" RepeatDirection="Horizontal" Width="23%" CellPadding="2" CellSpacing="0" Height="270px" HorizontalAlign="Center">

<ItemTemplate>
<asp:Image Width="200px" height="200px" ID="Image1" ImageUrl='<%# Bind("Name", "~/MMS/1 Box/{0}") %>' runat="server" />
<br />

<asp:HyperLink ID="HyperLink1" rel="lightbox[roadtrip]" title='<%# DataBinder.Eval(Container.DataItem, "LastWriteTime", "{0:yyyy-MM-dd   hh:mm:ss}") %>'
 Text="Zoom" NavigateUrl='<%# Bind("Name", "~/MMS/1 Box/{0}") %>' runat="server"/>
</ItemTemplate>
<ItemStyle BorderColor="Silver" BorderStyle="Dotted" BorderWidth="1px" HorizontalAlign="Center"

VerticalAlign="Bottom" />
</asp:DataList>

and to read the Images from folder my vb.net code is here

Sub loadimage()
        Dim sdir As New DirectoryInfo(MapPath("~/MMS/1 Box"))

        Dim file As FileInfo() = sdir.GetFiles()
        Dim list As New ArrayList()

        For Each file2 As FileInfo In file
            If file2.Extension = ".jpg" OrElse file2.Extension = ".gif" OrElse file2.Extension = ".bmp" Then

                list.Add(file2)

            End If

        Next

        DataList1.DataSource = list

        DataList1.DataBind()


    End Sub

Anyone tell me what change should i have to make in code so that my both requirements will be completed as well

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

守不住的情 2025-01-04 07:42:52

使用 IComparable 根据创建时间或您想要排序的任何属性对列表进行排序。

这是一个可以帮助您实现此目的的链接: http://www.knowdotnet.com/articles/ sortarraylistofobjects.html

Use IComparable to sort your list based on time creation time or whatever attribute you want to sort it.

Here is a link which would help you implement this: http://www.knowdotnet.com/articles/sortarraylistofobjects.html

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文