Check if conditions are OK for deleting records with gridview control in asp.net 3.5 web page
Posted on 2011-03-23
I am very new to creating asp.net websites, new to Visual Studio 2008 in general, and new to coding in VB. I am creating a web application to replace an MS Access app.
Right now I am seeking help with what code to place in an event handler, such as a Gridview's RowDeleting event, to peek around to see if the record about to be deleted is referenced in other tables.
In Access, for example on a form where the CustContactID to be deleted had been chosen from a combo box called cmbSelCustContactID, I would have had some code run on the form's BeforeDelConfirm event, something like:
Dim x as Integer
x = Dcount("ProjectID", "ProjectContacts", "CustContactID=" & me.cmbSelCustContactID)
If x > 0 then
MsgBox "The contact is associated with Project data. You may not delete them."
What can I put in the Gridview control's RowDeleting event handler to achieve the same result? Some way to instantiate a recordset in the code, then evaluate the recordset and use the results to drive subsequent code?