以表格形式将图片绑定到数据网格 [英] bind picture to a datagrid in a tabular fashion
本文介绍了以表格形式将图片绑定到数据网格的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我想以表格格式显示图片,但是下面带有以下代码,每张图片都保持垂直插入,
我希望图片以(*)4 * 4格式显示.请帮助我
I want to display picture in a tabular format,but with the following code below,each picture is keep inserted vertically,
i want picture to be displsy say in a(say)4 * 4 format.please help me
<asp:GridView ID="GridView1" runat="server" AllowPaging="True" AllowSorting="True"
AutoGenerateColumns="False" BackColor="White" BorderColor="#3366CC" BorderStyle="None"
BorderWidth="1px" CellPadding="4" Height="204px"
HorizontalAlign="Justify" PageSize="5" Width="56px" ShowHeader="False" >
<Columns>
<asp:TemplateField>
<ItemTemplate>
<asp:HyperLink ID="HyperLink1" runat="server" NavigateUrl='<%# geturl(DataBinder.Eval(Container.DataItem, "img_id"))%>'><asp:Image ID="Image1" runat="server" Height="40" ImageUrl='<%# FormatURL(DataBinder.Eval(Container.DataItem, "img_id")) %>'
Width="40" /></asp:HyperLink>
</ItemTemplate>
</asp:TemplateField>
</Columns>
<FooterStyle BackColor="#99CCCC" ForeColor="#003399" />
<SelectedRowStyle BackColor="#009999" Font-Bold="True" ForeColor="#CCFF99" />
<PagerStyle BackColor="#99CCCC" ForeColor="#003399" HorizontalAlign="Left" />
<HeaderStyle BackColor="#003399" Font-Bold="True" ForeColor="#CCCCFF" />
<PagerSettings NextPageImageUrl="photogallary.aspx" PageButtonCount="4" />
<RowStyle BackColor="White" ForeColor="#003399" />
</asp:GridView>
推荐答案
使用Datalist
代替GridView
.在数据列表中,使用属性RepeatColumns="4"
&RepeatDirection="Horizontal"
,仅此而已.
在数据库中的数据列表中显示图像 [动态将图像绑定到DataList控件 [
UseDatalist
instead ofGridView
. In Datalist use the propertiesRepeatColumns="4"
&RepeatDirection="Horizontal"
, that''s all.
Display images in DataList from Database[^]
Binding images to a DataList control dynamically[^]
这篇关于以表格形式将图片绑定到数据网格的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文