Jump to content
Software FX Community
jvwiv

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)

Share this post


Link to post
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>();

  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

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

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.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...

×
×
  • Create New...