【发布时间】:2011-09-28 20:15:19
【问题描述】:
iv'e 有一个中继器绑定到实体列表
BL_Engine engine = (BL_Engine)Application["engine"];
List<AppProduct> products = engine.Get_Products();
Repeater1.DataSource = products;
Repeater1.DataBind();
我还有一个用户控件用来表示这些产品实体,我通过覆盖用户控件中的 Databind() 来做到这一点:
public override void DataBind()
{
AppProduct product = (Page.GetDataItem() as AppProduct);
lbl_title.Text = product.Title;
lbl_short.Text = product.Short;
lbl_date.Text = product.Date.ToShortDateString();
Session["current_img"] = product.Image1;
base.DataBind();
}
在保存在 .ashx 文件中的 HttpHanlder 对象中,我将图像写入响应 响应只发生一次,因此只有最后一张图片被写入(全部)用户控件。
public void ProcessRequest(HttpContext context)
{
byte [] image = (byte[])context.Session["current_img"];
context.Response.ContentType = "image/bmp";
context.Response.OutputStream.Write(image, 0, image.Length);
}
知道如何为每个单独的控件编写二进制数据
提前致谢 伊兰
【问题讨论】:
标签: c# asp.net data-binding user-controls httphandler