对Datalist控件中的图片进行排序
我有一个数据列表控件并从文件夹中读取图片并将它们显示在数据列表的灯箱中我还从这些图片中读取数据和时间。第一件事是数据列表没有读取从属性中获取的日期图片,第二件事是图片未按拍摄日期的降序排序。请有人告诉我如何完成这些任务。 我的数据列表代码在这里
<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 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
使用 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