Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations John Tel on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

DataGrid Object reference not set to an instance of an object

Status
Not open for further replies.

bubberz

Programmer
Dec 23, 2004
117
US
Please see below "******" were error "Object referenece not set..." is happening:

Private Sub DataGrid1_UpdateCommand(ByVal source As Object, ByVal e As System.Web.UI.WebControls.DataGridCommandEventArgs) Handles DataGrid1.UpdateCommand

Dim key As String = DataGrid1.DataKeys(e.Item.ItemIndex).ToString()
Dim P3ActivityID As Integer, delivDesc As String
Dim tb As TextBox
tb = CType(e.Item.Cells(1).Controls(1), TextBox)
P3ActivityID = CStr(tb.Text)
tb = CType(e.Item.Cells(2).Controls(1), TextBox)
delivDesc = tb.Text
Dim r As dsGridDeliverables.WP_DeliverablesRow
r = DsGridDeliverables1.WP_Deliverables.FindByDeliverable_Number(key)
'******* @@ code errors at next line @@*******
r.Deliverable_Description() = delivDesc
r.Deliverable_Number() = P3ActivityID
OleDbDataAdapter1.Update(DsGridDeliverables1)
DataGrid1.DataBind()
DataGrid1.EditItemIndex = -1
DataGrid1.DataBind()
 
Everyone seems to be asking the same question today about the "Object Reference" error so I may as well use the same answer:
ca8msm said:
Although not in the ASP.NET forum, there is a good response to the very same question (Object Reference..) in Thread796-1043354. Read that and try to figure it out - it should be very simple.

--------------------------------------------------------------------------------------------------------------------------------------------

Need help finding an answer?

Try the search facility ( or read FAQ222-2244 on how to get better results.
 
I fixed the issue (at least for us) by calling the dataadapter fill method, and then databinding at the beginning of the Updatecommand for the Datagrid.

Now my issue is the OleDBDataAdapter.Update command is erroring with some syntax error. I'm trying to write the query to a label, and see what's up. Haven't figured it out yet...any tips to write the query to the label?
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top