954,574 Members — Technology Publication meets Social Media
Username:
Password:
Lost login information?
Have something to say? Contribute New Article Reply to this Article

Object reference not set to an instance of an object.

I am working on something for school as a final project before graduation.

I am using ASP for the website and VB as the back end to code.

I keep getting the error "Object reference not set to an instance of an object" and can't figure out what is wrong.

I am trying to using edit, update, cancel in the gridview for ASP

Imports System.Data.SqlClient
     
     
    Partial Public Class CheckInOut
    Inherits System.Web.UI.Page
    Sub OnDSUpdatedHandler(ByVal source As Object, ByVal e As SqlDataSourceStatusEventArgs)
     
    End Sub
    Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
     
     
    End Sub
    Private Sub BindData()
     
    End Sub
     
    Protected Sub checkInOutGV_SelectedIndexChanged(ByVal sender As Object, ByVal e As EventArgs) Handles checkInOutGV.SelectedIndexChanged
     
    End Sub
     
    Protected Sub pullUpChildRecords_Click(ByVal sender As Object, ByVal e As EventArgs) Handles pullUpChildRecords.Click
    Dim connection As New SqlConnection("Data Source=Steven-PC;Integrated Security=True")
    Dim sqlstatement As String = "SELECT pickUpPerson FROM CheckInOut WHERE childID = " & childIDText.Text & ""
    Try
    Dim command As SqlCommand
    command = New SqlCommand(sqlstatement, connection)
    Catch
    checkInOutGV.Visible = False
    End Try
    'checkInOutGV.Visible = True
     
    End Sub
    Protected Sub GridView1_RowCommand(ByVal sender As Object, ByVal e As GridViewCommandEventArgs)
    End Sub
     
    Protected Sub checkInOutGV_RowUpdating(ByVal sender As Object, ByVal e As System.Web.UI.WebControls.GridViewUpdateEventArgs)
    Dim update = CType(Session("CHeckinOut"), DataTable)
     
    'Update the values.
    Dim row = checkInOutGV.Rows(e.RowIndex)
    update.Rows(row.DataItemIndex)("time_in") = (CType((row.Cells(1).Controls(0)), TextBox)).Text
    update.Rows(row.DataItemIndex)("time_out") = (CType((row.Cells(2).Controls(0)), TextBox)).Text
    update.Rows(row.DataItemIndex)("childName") = (CType((row.Cells(3).Controls(0)), CheckBox)).Checked
    update.Rows(row.DataItemIndex)("dropOffPerson") = (CType((row.Cells(4).Controls(0)), TextBox)).Text
    update.Rows(row.DataItemIndex)("pickUpPerson") = (CType((row.Cells(5).Controls(0)), TextBox)).Text
    update.Rows(row.DataItemIndex)("staffID") = (CType((row.Cells(6).Controls(0)), CheckBox)).Checked
    update.Rows(row.DataItemIndex)("childID") = (CType((row.Cells(7).Controls(0)), CheckBox)).Checked
     
     
    'Reset the edit index.
    checkInOutGV.EditIndex = -1
     
    'Bind data to the GridView control.
    BindData()
    End Sub
     
    Protected Sub checkInOutGV_RowEditing(ByVal sender As Object, ByVal e As System.Web.UI.WebControls.GridViewEditEventArgs)
    checkInOutGV.EditIndex = e.NewEditIndex
     
    BindData()
    End Sub
     
    Protected Sub childIDText_TextChanged(ByVal sender As Object, ByVal e As EventArgs) Handles childIDText.TextChanged
     
    End Sub
     
    Protected Sub checkInOutGV_RowCancelingEdit(ByVal sender As Object, ByVal e As System.Web.UI.WebControls.GridViewCancelEditEventArgs) Handles checkInOutGV.RowCancelingEdit
    checkInOutGV.EditIndex = -1
     
    BindData()
    End Sub
     
    Protected Sub checkInOutGV_PageIndexChanging(ByVal sender As Object, ByVal e As System.Web.UI.WebControls.GridViewPageEventArgs) Handles checkInOutGV.PageIndexChanging
    checkInOutGV.PageIndex = e.NewPageIndex
     
    BindData()
    End Sub
    End Class


That is what I have so far any help would be nice. Thanks. After this just need to get data to only show up to what I enter into text box. For some reason the data in the data grid loads up without me asking it to. I want it to be hidden till i enter say 2 into the textbox and only show the data from "childID" that is 2. This I can figure out in acouple hours really need help with the update though been trying to work on it and find it for days now. It is making my head hurt. Can only find people doing it in C#.

Thanks for any help.

StevenSchaffner
Newbie Poster
16 posts since Aug 2011
Reputation Points: 10
Solved Threads: 0
 

So what line gives the error? You could narrow down the search for us a bit:)

hericles
Practically a Posting Shark
823 posts since Nov 2007
Reputation Points: 136
Solved Threads: 167
 

I got it to work. I did my things in ASP.

StevenSchaffner
Newbie Poster
16 posts since Aug 2011
Reputation Points: 10
Solved Threads: 0
 
I got it to work. I did my things in ASP.

Thanks to me Steve, lol. Are you having anymore trouble with it?

TheJohnSpecko
Newbie Poster
22 posts since Nov 2010
Reputation Points: 10
Solved Threads: 3
 

Naw you helped me with something else xD

got edit, update to work on my own. Need help with adding row to datagrid

StevenSchaffner
Newbie Poster
16 posts since Aug 2011
Reputation Points: 10
Solved Threads: 0
 

This question has already been solved

Post: Markdown Syntax: Formatting Help
You
View similar articles that have also been tagged: