2015-10-16 63 views
0

我正在開發一個asp.net web應用程序使用web數據庫的形式。在我的應用程序已存儲的圖像文件夾中,併爲圖片鏈接存儲在數據庫中 我希望通過採取這些鏈接從數據庫 顯示這些圖片我嘗試了以下代碼來顯示圖像如何顯示數據庫所採取的鏈接圖像

home.aspx的.cs

 protected void Page_Load(object sender, EventArgs e) 
    {  
     profile_picture = (string)(Session["link"]); //link has been taken from db 
    } 

home.aspx

<asp:Image runat="server" ID="profile_picture" ImageUrl="Label"></asp:Image> 

錯誤是=>錯誤4無法隱式轉換類型 '字符串' 到 'System.Web.UI.WebControls.Image' 如何解決? 謝謝。

回答

0
profile_picture.ImageUrl = (string)(Session["link"]); 

這應該有所幫助。不知道如果ImageUrl是正確的屬性,但看看System.Web.UI.WebControls.Image這是什麼「profile_picture」是typeOf,看看圖像鏈接應設置爲什麼屬性。