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

C# 如何在asp中继器中动态更改图像大小而不将图像大小存储在数据库中,c#,css,asp.net,.net,C#,Css,Asp.net,.net,我有以下中继器: <asp:Repeater runat="server" ID="rptnewfeeds"> <ItemTemplate> <div id="main" role="main" style="width: 1153px; margin-top: -105px; left: 105px; position: absolute;">

我有以下中继器:

          <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>
现在是将所有
图像绑定为相同大小
,但我希望将所有图像绑定为
不同大小

例如,假设现在10个图像的宽度为200,高度为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") %>'

你能举例说明吗?这完全取决于你的要求。您想要的高度/宽度是多少?我想要高度=200,宽度=200,其他图像的高度应该更改。在执行rptnewfeed.DataBind()之前,请将该部分编码到额外的列中,这样您就可以了
 <asp:Image ID="Image4" runat="server" Height='<%#Eval("H") %>'