简体   繁体   中英

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

for example suppose now the 10 images has 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.

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

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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