我有有图像控制有时这个图像控制hadnot数据,我想隐藏它,当它没有数据时,我做了代码,但它显示为图像没有数据(不可用),请任何人帮我的Repeater控制。 注:数据来自数据的基础上使图只好标识从数据库中,但没有值(NULL)如何在没有URL的情况下隐藏图像控件?
protected void DLHome_ItemDataBound(object sender, RepeaterItemEventArgs e)
{
Image Img = e.Item.FindControl("ModelLogo") as Image;
using (SqlConnection con = Connection.GetConnection())
{
string Sql = "Select Logo From Model";
SqlCommand com = new SqlCommand(Sql, con);
com.CommandType = CommandType.Text;
SqlDataReader dr = com.ExecuteReader();
if (dr.Read())
{
string Img2 = dr["Logo"].ToString();
if (Img2 == System.DBNull.Value.ToString())
{
Img.Visible = false;
}
}
}
}
注:数据来自数据的基础上使图只好标识从数据库中,但没有值(NULL) – Myworld 2010-08-24 07:03:16