用默认图像替换空白图像 [英] Replace blank images with default image

查看:152
本文介绍了用默认图像替换空白图像的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在我的程序中,我将图像存储在数据库中。并非数据库中的所有记录都有图像,当我将细节加载到另一个.aspx页面时,有时图像为空 - 有一个红色的x。如何替换x?使用默认图像?

In my program I am storing images in the database. Not all of the records in the database have images, and when I load the details into another .aspx page, sometimes the image is empty- has a red "x". How do I replace that "x" with a default image?

推荐答案



可能是这样的:

选项#1:In您的数据库将图像列的默认值设置为默认图像,因此如果它为空(添加新行),将设置默认值。

(实际上我没有添加图像之前的db,只有pathesStrings)。这很简单。

选项#2:您可以检查PictureBox的ImageLocation属性,如果等于String.Empty这是一个字符串,那么没有图像然后您必须分配一个。

我更喜欢选项#1,我希望其中一个能提供帮助。
Hey
It might be like this :
Option#1 : In your database set the default value for the image column to your default image, so if it is empty (at new row added) the default value will be set.
(actually I didn''t add images to db before, only pathes "Strings"). This is very easy.
Option#2 : You may check the ImageLocation property of the PictureBox, this is a string if equal to String.Empty so there is no image then you''ve to assign one.
I prefer Option#1, I hope one of them will help.


嘿,谢谢你的回复,我没有一个图片框而是一个图像标签。
Hey, thanks for your response, I don''t have a picture box, rather an image tag.
展开 | 选择 | Wrap | < span class =codeLinkonclick =LineNumbers(this);>行号


实际上,我认为我想要真正实现的是:


如果图片字段的值为null,我想要显示这个blank.gif图像,表示没有可用的图像。
Actually, I think what I want to really accomplish is this:

If the value of the picture field is null, I want to show this blank.gif image which says that there is no image available.


这篇关于用默认图像替换空白图像的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆