单元格显示图片问题
郭工:A页面的Gridview显示数据列表,由列ID调用B页面,B页面的FpSpread的单元格用下列代码显示图片:
//链接数据源,取得数据集
if (Ds.Tables.Rows.Count > 0)
{
FpSpreadFile.DataSource = Ds.Tables;
FpSpreadFile.DataBind();
FpSpreadFile.Sheets.Columns.Width = 200;
for (int I = 0; I < Ds.Tables.Rows.Count; I++)
{
byte[] photo = new byte;
photo = (byte[])Ds.Tables.Rows;
TypeConverter tc = TypeDescriptor.GetConverter(typeof(Bitmap));
Bitmap bm = (Bitmap)tc.ConvertFrom(photo);
string FileName = "~/Image/Image" + (I + 1).ToString() + ".jpg";
if(File.Exists (FileName ))
{
try
{
File.Delete(FileName);
}
catch (Exception ex)
{
throw ex;
}
}
bm.Save(Server.MapPath(FileName));
FpSpreadFile.ActiveSheetView.Cells.Value = null;
FarPoint.Web.Spread.ImageCellType ict = new FarPoint.Web.Spread.ImageCellType();
FpSpreadFile.ActiveSheetView.Cells.CellType = ict;
ict.TextOnRight = false;
ict.ImageAlign = ImageAlign.AbsMiddle;
//ict.ImageUrl = "~/Image/Image" + (I + 1).ToString() + ".jpg";
ict.ImageUrl = FileName;
ict.CssClass = "test";
}
}
FpSpreadFile.SaveChanges();
Ds.Dispose();
Da.Dispose();
第一次显示图片正确,关闭B页面,重新选择另一ID再打开B页面,显示的图片还是上一次ID的图片,如何设置?保证图片更新?
您好,代码看着没什么问题,您这个 I是什么变量,你需要确认这个值有发生变化
页:
[1]