如何在asp中继器中动态更改图像大小而不将图像大小存储在数据库中
本文关键字:图像 数据库 存储 asp 中继器 动态 | 更新日期: 2023-09-27 18:27:14
我有以下中继器:
<asp:Repeater runat="server" ID="rptnewfeeds">
<ItemTemplate>
<div id="main" role="main" style="width: 1153px; margin-top: -105px; left: 105px; position: absolute;">
<ul id="tiles">
<li>
<asp:Image ID="Image4" runat="server" ImageUrl='<%#Eval("image") %>' />
</li>
</ul>
</div>
</div>
</ItemTemplate>
</asp:Repeater>
代码:-
DataSet ds = new DataSet();
string select = "select image from UserProfileData where date>='2013-09-01'";
SqlDataAdapter da = new SqlDataAdapter(select, _connect());
da.Fill(ds);
rptnewfeeds.DataSource = ds;
rptnewfeeds.DataBind();
现在它绑定了所有的the images as same size
,但我想将所有图像作为different size
例如,假设现在10个图像具有width=200 and height=200
now i want like 1st image has width=200 and height=300
2nd image has width=200 and height=283
3rd image has width=200 and height=230
...
... and so on
那么我该怎么做呢?
如何在中继器中获得图像的所有随机高度?
知道吗?
在数据绑定之前,将一列(在本例中为H表示高度)添加到包含所需高度的数据集中。
ds.Tables[0].Columns.Add("H", typeof(int));
用所需的高度填充每行的此列。可以是随机的,也可以是你想要的值。
在中继器中,数据绑定到此新列
<asp:Image ID="Image4" runat="server" Height='<%#Eval("H") %>'
宽度相同。。