Jump to content
Software FX Community

Manually Deleting a record


Recommended Posts

GridFX does a nice job of deleting records from our bound forms, but now I want to override the default behavour and perform some checks prior to deleting the record.  I can perform the checks via a stored proc and can have the grid call the stored proc, but I am unsure how to pass the forms key to my stored proc.  Thus, I took a different route, using a sub I had coded to execute the stored proc.  I am now trying to pass in a variable to the stored proc from the grid.  I have tried to use keyfield = e.datavalues.item("ItemID") to set a variable to the key field I wish to delete.  When ever I run the application I get an error. The results are

 NullReferenceException was handled by user code.  Object reference not set to an instance of an object.

What am I doing wrong?  How would I pass a parameter to the data source from the grid to fire the stored proc there? (Preferred)

Link to comment
Share on other sites

I think you are close to get it done. Following is a code sample that will help you.

In this case we are passing the item key value to a Business Object class that you can easily use to call your stored procedure.

protected void Grid1_ItemDeleting (object sender,GridFX.WebForms.GridItemDeletingEventArgs e)


  e.DataValues.GetPrimaryKey <int>();


  e.Handled = true; 


Give it a try it and if you continue receiving the same error, send us your server side code and web page markup so we can see what is happening. You can write us to support@online.softwarefx.com (remove online).

Let me know how it goes.


Link to comment
Share on other sites

OK, got past the e.datavalues.primarykey(of Integer)() issue, but now am getting the same error once again. 

reservationID = e.DataValues.GetPrimaryKey(

Of Integer)()

The error I receive is that the e.DataValues has a null reference.  (VB.Net)

This is during the ItemDeleting event.


Link to comment
Share on other sites


This topic is now archived and is closed to further replies.

  • Create New...