2011-07-22 58 views
0

我在我的數據庫中存儲圖像數據類型。 但是,儘管檢查它在gridview中檢查空值

<asp:LinkButton ID="lbEvidence" runat="server" 
         Text='<%# CheckNull (Eval("Evidence")) %>' 

aspx.cs

protected string CheckNull(object objGrid) 
     { // checks whether there is evidence file or not 

      if (object.ReferenceEquals(objGrid, DBNull.Value)) 
      { 
       return ""; 

      } 
      else 
      { 
       return "Record Found";    
      } 
     } 

即使在DB的圖像是NULL,這裏objgrid取值System.Byte [4],並返回找到的記錄。 工作正常時,圖像不是null

任何提示 孫

+0

在此設置中斷點:如果(object.ReferenceEquals(objGrid,DBNull.Value)),並且在不久的窗口,看objGrid的值 – TheGeekYouNeed

+0

@TheGeekYouNeed:objGrid = System.Bytes [4]表中的NULL。否則它是System.Bytes [....] – Sun

回答

0

,當你這樣做會發生什麼?

protected string CheckNull(object objGrid) 
     { // checks whether there is evidence file or not 

      return (object == null) ? string.empty : "Record Found"; 
     } 
+0

不變。如果數據庫中的圖像爲NULL,則objGrid正在接受System.Byte [4] – Sun

+0

objGrid在圖像時與objGrid相等是什麼?數據庫中的空值是否設置爲數據層中的另一個值? – FiveTools

+0

:objGrid需要System.Byte [] Text ='<%#CheckNull(Eval(「Evidence」))%>'。表中的證據是圖像數據類型。 – Sun