我有一个listview显示像ImageViewer这样的图像,我想在ListView中实现拖放行为。请让我知道如何在下面的自定义ListView中实现Srag-Drop。
<asp:ListView ID="lvPhotoViewer" runat="server" GroupItemCount="3" InsertItemPosition="LastItem">
<LayoutTemplate>
<table id="groupPlaceholderContainer" runat="server" border="1">
<tr id="groupPlaceholder" runat="server">
</tr>
</table>
</LayoutTemplate>
<ItemTemplate>
<td id="Td4" align="center" style="background-color: #eeeeee;">
<asp:Image runat="server" ID="imPhoto" Height="100px" Width="100px" ImageUrl='<%# "~"+Eval("PhotoUrl") %>' />
<br />
<asp:Label ID="DefaultPhotIDLabel" runat="server" Text='<%# Eval("PhotoName") %>' />
</td>
</ItemTemplate>
<GroupTemplate>
<tr id="itemPlaceholderContainer" runat="server">
<td id="itemPlaceholder" runat="server">
</td>
</tr>
</GroupTemplate>
<InsertItemTemplate>
<td id="Td3" width="150px" height="150px" runat="server" align="center" style="background-color: #e8e8e8;
color: #333333;">
<asp:FileUpload ID="fileUpload" runat="server" />
</td>
</InsertItemTemplate>
</asp:ListView>
代码背后:
public class ImageEntity
{
public string PhotoName { get; set; }
public int PhotoIndex { get; set; }
public string PhotoURL { get; set; }
}
public partial class _Default : System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
{
IList<ImageEntity> imagesList = new List<ImageEntity>()
{
new ImageEntity(){ PhotoName="House1", PhotoIndex=1, PhotoURL= @"\Images\House-01.JPG" },
new ImageEntity(){ PhotoName="House2", PhotoIndex=2, PhotoURL= @"\Images\House-05.JPG" },
new ImageEntity(){ PhotoName="House3", PhotoIndex=3, PhotoURL= @"\Images\house.jpg" },
new ImageEntity(){ PhotoName="House4", PhotoIndex=4, PhotoURL= @"\Images\house2.jpg" }
};
lvPhotoViewer.DataSource = imagesList;
lvPhotoViewer.DataBind();
}
}
请为我建议一种在ListView中实现图像拖放的方法
答案 0 :(得分:2)
考虑使用JQuery拖放式UI功能:http://jqueryui.com/demos/draggable/和http://jqueryui.com/demos/droppable/。
此外,如果您想拖放行,请查看以下内容:jQuery draggable table elements
HTH。