jvwiv Posted February 28, 2008 Report Share Posted February 28, 2008 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) Quote Link to comment Share on other sites More sharing options...
AngelR Posted February 28, 2008 Report Share Posted February 28, 2008 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>(); AgentsDataService.DeleteAgent(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. Quote Link to comment Share on other sites More sharing options...
jvwiv Posted February 29, 2008 Author Report Share Posted February 29, 2008 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. Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.