Advertisement

06.25.2008 at 01:09PM PDT, ID: 23516041
[x]
Attachment Details

ASP.Net 2.0 VS2005 NullReference Error

Asked by ttinsley in .Net Editors & IDEs, Visual Basic Programming, .NET

I have a button in each line of my gridview which fires a stored procedure but  want to disable the button if two of the values returned on that same line are equal. No matter what I try I keep getting the same error message during runtime stating that "btn.text is Null and that I should use new to create a new instance of that object.

I used the same basic code on a checkbox in another page and it works beutifully, What am I missing?Start Free Trial
1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
11:
Sub GridView1_DataBound(ByVal sender As Object, ByVal e As System.Web.UI.WebControls.GridViewRowEventArgs) Handles GridView1.RowDataBound
        If e.Row.RowType = DataControlRowType.DataRow Then
            Dim btn As Button = e.Row.FindControl("Receive")
            Dim QtySent As Integer = CInt(e.Row.Cells(7).Text)
            Dim QtyReceived As Integer = CInt(e.Row.Cells(8).Text)
            If QtyReceived = QtySent Then
                btn.Text = "test"
            End If
 
        End If
    End Sub
[+][-]06.25.2008 at 01:26PM PDT, ID: 21869546

View this solution now by starting your 7-day free trial. Setting up your free trial is quick, easy, and secure. We will return you to this solution, unlocked, when you're done.

 

About this solution

Zones: .Net Editors & IDEs, Visual Basic Programming, .NET
Sign Up Now!
Solution Provided By: Chumad
Participating Experts: 1
Solution Grade: A
 
 
 
Loading Advertisement...
20080716-EE-VQP-32 / EE_QW_2_20070628