繁体   English   中英

如何在ASP中继器中动态更改图像大小而不在数据库中存储图像大小

[英]how to change the image size dynamically in asp repeater without store the image size in database

我有以下中继器:

          <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") %>'

宽度相同

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM