-
DataList Image Nhibernate 数据绑定
日期:2009-03-12 | 分类:.net
版权声明:转载时请以超链接形式标明文章原始出处和作者信息及本声明
http://alek.blogbus.com/logs/36470574.html
protected void DataListImages_ItemDataBound(object sender, DataListItemEventArgs e)
{
if (e.Item.ItemType == ListItemType.Item || e.Item.ItemType == ListItemType.AlternatingItem)
{
Tjgdcpic info = (Tjgdcpic)e.Item.DataItem;Image Image1 = (Image)e.Item.FindControl("Image1");
//xjjgdc_images
AppSettingsReader reader = new AppSettingsReader();
string image_locate = reader.GetValue("Image_locate", typeof(string)).ToString().Trim();Image1.ImageUrl = image_locate + info.Realfilename;
string image_file_name =info.Realpath.Trim() + "\\" + info.Realfilename;
if (System.IO.File.Exists(image_file_name))
{
using (System.Drawing.Image img = System.Drawing.Image.FromFile(image_file_name))
{
if ((img.Width > 640) || (img.Height > 640))
{
//
decimal width = img.Width;
decimal height = img.Height;
int newwidth, newheight;string fbl_str = reader.GetValue("PicZuiDaFenbianlv", typeof(string)).ToString().Trim();
int fbl = int.Parse(fbl_str);if (width > height)
{
newwidth = fbl;
newheight = (int)(height / width * fbl);
}
else
{
newheight = fbl;
newwidth = (int)(width / height * fbl);
}
Image1.Width = newwidth;
Image1.Height = newheight;
}
else
{
Image1.Width = img.Width;
Image1.Height = img.Height;
}
}
}}
}随机文章:
VS2005 TreeView 的 CheckBox 被点击时 2008-10-08Nhibernate 1.2以上版本需要注意的事项 2008-08-18C#实现的18位身份证格式验证算法 2007-08-06JSGLDBOperator.cs 2007-06-23关于日期的正则表达式,包括闰年 2007-06-06
收藏到:Del.icio.us







