0

i receive the error when my web app is published. when i run the app it works fine.

im using vs 2010

this is the line of code where it errors:

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

the aim is to have a look in the footer on the gridview and then remove the £ sign so that it no longer exist

i rowdatabound the information from an excel spreadsheet to the 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

can anyone help please

4

1 回答 1

0

在此行中:

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

在哪里total初始化?

如果它没有被初始化,那么当你在这里通过 Cells(1) 访问它时:

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

你会得到 NullReferenceException

于 2013-10-23T11:07:24.623 回答