【问题标题】:Drag Drop items within ListView in ASP.Net在 ASP.Net 中的 ListView 中拖放项目
【发布时间】:2011-03-11 13:34:32
【问题描述】:

我有一个显示 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 中实现图像拖放的方法

【问题讨论】:

  • 你想拖放...什么?在哪里?你想对图像进行排序,还是..?
  • 我有一个列表视图控件,我在其中使用 ItemTemplate 显示图像。现在我想将这些图像拖放到它们自己内部以重新排列列表视图中的图像。我想使用拖放重新排序图像。

标签: asp.net listview drag-and-drop


【解决方案1】:

考虑使用 JQuery 拖放 UI 功能:http://jqueryui.com/demos/draggable/http://jqueryui.com/demos/droppable/

另外,如果您想拖放行,请查看:jQuery draggable table elements

HTH。

【讨论】:

  • 感谢 Brain.. 该解决方案看起来很完美,但小型演示应用程序确实会有所帮助。我对 JQuery 很陌生,所以如果可能的话,请您指向一个示例应用程序,其中可以拖放 Listview 中的图像?
  • 大脑,您提供的链接确实有帮助。我可以用它实现拖放功能..
猜你喜欢
  • 2014-07-11
  • 2016-04-02
  • 1970-01-01
  • 2013-01-05
  • 2016-03-26
  • 1970-01-01
  • 1970-01-01
  • 2014-04-20
  • 2012-11-24
相关资源
最近更新 更多