如何更改数据列表图像的顺序从左到右或从右到左?
我有一个数据列表和 2 个按钮生命权,位于数据
列表之外:
<asp:DataList ID="dlst" runat="server" RepeatDirection="Horizontal"
RepeatColumns="5" CellSpacing="8">
<ItemTemplate>
<asp:ImageButton ID="Image" runat="server" ImageUrl='<%#"~/Controls/Showimg.ashx?FileName=" +DataBinder.Eval(Container.DataItem, "FilePath") %>' OnCommand="ImageSelect_Command" CommandArgument='<%# Eval("Id").ToString() +";"+Eval("FilePath")+";"+Eval("Index")+";"+Eval("FileName") %>' /><br />
<asp:Label ID="nlbl" runat="server" Text="Figure"></asp:Label><%# dlst.Items.Count + 1%>
</ItemTemplate>
</asp:DataList>
按钮:
<asp:ImageButton ID="btnleft" runat="server" ImageUrl="~/images/arrowLBlue.png"
ToolTip="Move Item Left" OnClick="btnleft_Click" />
<asp:ImageButton ID="btnright" runat="server" ImageUrl="~/images/arrowRBlue.png"
ToolTip="Move Item Right" />
我正在上传和绑定图像,其工作正常,现在我想在单击按钮时将选定的图像从左向右或从右向左移动,假设我有图像 a1、a2、a3、a4、a5,并且在选择图像 a2 后单击了 btnmoveright 那么图像顺序应该是 a1、a3、a2、a4、a5 现在如果我再次单击btn选择图像a2后向右移动,那么顺序应该是a1,a3,a4,a2,a5,像这样我想移动图像。 怎么做呢?请有人帮助我
I have a datalist and 2 button life right which is outside of datalist
datalist:
<asp:DataList ID="dlst" runat="server" RepeatDirection="Horizontal"
RepeatColumns="5" CellSpacing="8">
<ItemTemplate>
<asp:ImageButton ID="Image" runat="server" ImageUrl='<%#"~/Controls/Showimg.ashx?FileName=" +DataBinder.Eval(Container.DataItem, "FilePath") %>' OnCommand="ImageSelect_Command" CommandArgument='<%# Eval("Id").ToString() +";"+Eval("FilePath")+";"+Eval("Index")+";"+Eval("FileName") %>' /><br />
<asp:Label ID="nlbl" runat="server" Text="Figure"></asp:Label><%# dlst.Items.Count + 1%>
</ItemTemplate>
</asp:DataList>
buttons:
<asp:ImageButton ID="btnleft" runat="server" ImageUrl="~/images/arrowLBlue.png"
ToolTip="Move Item Left" OnClick="btnleft_Click" />
<asp:ImageButton ID="btnright" runat="server" ImageUrl="~/images/arrowRBlue.png"
ToolTip="Move Item Right" />
I am uploading and binding the images its working fine, now I want to move a selected image from left to right or right to left on my button click, suppose i have image a1, a2, a3, a4, a5 and i clicked on btnmoveright after selecting the image a2 then the image order should be a1,a3,a2,a4,a5 now if again i clicked on btnmoveright after selecting the image a2 then order should be a1,a3,a4,a2,a5 like this I want to move the image.
How to do that? Please someone help me
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
看起来数据列表的数据源是表示文件路径的字符串的集合。如果是这样,只需将所选项目与左侧或右侧的项目交换并重新绑定即可。
您可以将集合存储在视图状态或会话对象中,以便在回发后轻松重新实例化它,而无需重新查询原始源。
It looks like the datasource for your datalist is a collection of strings representing the filepaths. If so, just swap the selected item with the one to the left or the right and rebind.
You can store the collection in the viewstate or in a session object to reinstantiate it easily after postback without requerying the original source.