您好,我正在做一个学校项目,我有一个带有图像的页面,我正在从 MySQL 数据库中检索它,但是增加图像渲染的任何方法都很慢?
任何帮助都会很棒:)
我的代码
<asp:DataList ID="dlst" runat="server" DataKeyField="ProductID" DataSourceID="SqlDataSource1" RepeatDirection="Horizontal" RepeatColumns="3" >
<HeaderTemplate>
</HeaderTemplate>
<ItemTemplate>
<asp:ImageButton ID="btnpopup" runat="server" ImageUrl='<%# "GetImage.aspx?id=" + Eval("ProductID") %>' Width="200px" Height="200px" CommandArgument='<%#Eval("ProductID") %>' CommandName="popup" CausesValidation="false" BorderStyle="Dotted" BorderColor="WhiteSmoke" />
</ItemTemplate>
</asp:DataList>
<asp:SqlDataSource ID="SqlDataSource1" runat="server"
ConnectionString="<%$ ConnectionStrings:smokeshopConnectionString %>"
ProviderName="<%$ ConnectionStrings:smokeshopConnectionString.ProviderName %>"
SelectCommand="SELECT ProductID, Name, Description, ProductImage FROM products"></asp:SqlDataSource>
我的第二页称为 GetImage
string id = Request.QueryString["id"];
MySqlDataReader r = db.getImage(id);
while(r.Read())
{
byte[] imgData = (byte[])r["ProductImage"];
Response.BinaryWrite(imgData);
Response.Flush();
}