在GridView中的同一字段中分隔数据 [英] separate data within the same field in GridView

查看:64
本文介绍了在GridView中的同一字段中分隔数据的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

嗨专家,



在GridView我有一个图像字段,它是一个如下的超链接:



Hi Experts,

in a GridView I have an image field, it's a hyperlink like below:

<asp:TemplateField HeaderText="Images">                                         <ItemTemplate>
<asp:HyperLink runat="server" ID="filesImages" NavigateUrl='<%#string.Format("http://abc.com/ic_images/commonfiles/ICImages/{0}",Eval("FILES")) %>' Font-Underline="true" Target="_blank"><%#Eval("FILES") %></asp:HyperLink>
 </ItemTemplate>
</asp:TemplateField>





这将在新窗口中以大尺寸显示图像。代码工作得很好,但问题是在表中我有多个图像用于由(|)分隔的相同记录,例如在 FILES 字段中我可以有image.jpg或image1 .jpg | image2.jpg | image3.jpg ...等

有没有办法按照它们在表格中的方式显示这些图像,但是当点击时会为每个图像显示不同的图像?< br $> b $ b

我希望我能很好地解释我的观点,请指教!



提前致谢

Samira



That will display the image in a big size in new window. The code is working very well, BUT the problem is in the table I have more than one image for the same record separated by (|), for example in FILES field I could have image.jpg OR image1.jpg|image2.jpg|image3.jpg ... etc
Is there a way to display those images the way they are in the table but when click will display different image for each one separated?

I hope i well explained my point, please advise!

Thanks in advance
Samira

推荐答案

这样的事情应该有效:

Something like this should work:
<asp:TemplateField HeaderText="Images">
<ItemTemplate>
    <asp:ListView runat="server" DataSource='<%# Eval("FILES", "{0}").Split(&apos;|&apos;) %>'>
    <LayoutTemplate>
        <ul>
            <li id="itemPlaceholder" runat="server" />
        </ul>
    </LayoutTemplate>
    <ItemTemplate>
        <li><asp:HyperLink runat="server"

            NavigateUrl='<%# string.Format("http://abc.com/ic_images/commonfiles/ICImages/{0}", Container.DataItem) %>'

            Text='<%# Container.DataItem %>'

            Font-Underline="true"

            Target="_blank"

        /></li>
    </ItemTemplate>
    </asp:ListView>
</ItemTemplate>
</asp:TemplateField>


这篇关于在GridView中的同一字段中分隔数据的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆