Jump to content
Software FX Community
jvwiv

Manually Deleting a record

Recommended Posts

jvwiv    0

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)

Share this post


Link to post
Share on other sites
AngelR    0

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.

 

Share this post


Link to post
Share on other sites
jvwiv    0

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.

 

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

×