我有有圖像控制有時這個圖像控制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