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 & ""
    Dim command As SqlCommand
    command = New SqlCommand(sqlstatement, connection)
    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.
    End Sub
    Protected Sub checkInOutGV_RowEditing(ByVal sender As Object, ByVal e As System.Web.UI.WebControls.GridViewEditEventArgs)
    checkInOutGV.EditIndex = e.NewEditIndex
    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
    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
    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.

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

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

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

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

Naw you helped me with something else xD

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

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.