2013-10-23 109 views
0

我的網站應用發佈時收到錯誤消息。當我運行該應用程序,它工作正常。gridview System.NullReferenceException:未將對象引用設置爲對象的實例。

IM使用VS 2010

這是代碼行其錯誤:

Dim money As String = footer.Cells(1).Text.Replace("£", String.Empty) 

的目的是讓在GridView的頁腳看看,然後取下£符號,使它不再存在

我的RowDataBound從Excel電子表格中的信息到girdview

Protected Sub GridView5_RowDataBound(ByVal sender As Object, ByVal e As System.Web.UI.WebControls.GridViewRowEventArgs) Handles GridView5.RowDataBound 
    If e.Row.RowType = DataControlRowType.Footer Then 
     e.Row.Cells(0).Text = "Total" 
     e.Row.Cells(1).Text = total.ToString("c") 
    End If 


End Sub 

誰能幫助請

+0

顯示在GridView標記過 –

回答

0

在這條線的位置:

e.Row.Cells(1).Text = total.ToString("c") 

哪裏total初始化?

如果沒有初始化,然後當你來到經細胞(1)這裏訪問:

Dim money As String = footer.Cells(1).Text.Replace("£", String.Empty) 

你將得到的NullReferenceException

相關問題