简体   繁体   English

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

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

i have the following repeater: 我有以下中继器:

          <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>

code: - 代码:-

        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();

now it is bind all the images as same size but i want to all images as different size 现在它绑定所有the images as same size但我要所有图像为different size

for example suppose now the 10 images has width=200 and height=200 例如,假设现在这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

so how can i do this ? 那我该怎么办呢?

how can i get the all random height of images in repeater ? 如何获得中继器中图像的所有随机高度?

any idea? 任何想法?

Before databinding, add a column, in this example H for height to your dataset containing the height and you need. 在数据绑定之前,在包含高度的数据集中添加一列,在本示例中为H,其中包含高度。

ds.Tables[0].Columns.Add("H", typeof(int));

Fill this column for each row with the height you need. 用所需的高度为每一行填充此列。 Either random or with some value you want. 可以是随机的,也可以是您想要的值。

In the repeater, databind to this new columns 在转发器中,将数据绑定到此新列

 <asp:Image ID="Image4" runat="server" Height='<%#Eval("H") %>'

Same for width.. 宽度相同

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

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