I'm working on an admin page for a SQL Server 05 db. The page is in ASP.NET 2.0/C#. The db has multiple tables with foreign keys/constraints.
I have multiple SqlDataSources and GridViews, which are doing the select/update/delete methods. I manually did the Insert method for each Gridview and I am able perform error handling on it.
But if I try to delete from one table with a constraint I get the ugly error screen. I want to be able to do error handling for the Delete method of the SqlDataSource.
So what I tried was just like the Insert. I set the OnClick property of the Delete button in the GridView to a new method that calls sdsServices.Del ete(). I get this error though:
"You have specified that your delete command compares all values on SqlDataSource 'sdsServices', but the dictionary passed in for values is empty. Pass in a valid dictionary for delete or change your mode to OverwriteChange s. "
Anything I try to delete on the GridView gets the error. After trying a few different things with that, I looked around found some info that said to use the OnDeleted or OnDeleting for the Gridview and use SqlDataSourceEv entArgs for either of those, which allows for error handling.
When I tried it with OnDeleting I would just get an error saying there was no overload for those EventArgs. When I tried it with OnDeleted I would get no errors, but nothing would delete from the GridView.
I hope I have explained this clearly enough. Can anyone point me in the right direction?
I have multiple SqlDataSources and GridViews, which are doing the select/update/delete methods. I manually did the Insert method for each Gridview and I am able perform error handling on it.
Code:
Textboxes for data to add
<asp:Button ID="btnInsertNewService runat="server" Text="Submit" OnClick="btnInsertNewService_Click" />
protected void btnInsertNewService_Click(object sender, EventArgs e)
{
try
{
sdsServices.Insert();
}
catch...Error Handling here...
So what I tried was just like the Insert. I set the OnClick property of the Delete button in the GridView to a new method that calls sdsServices.Del ete(). I get this error though:
"You have specified that your delete command compares all values on SqlDataSource 'sdsServices', but the dictionary passed in for values is empty. Pass in a valid dictionary for delete or change your mode to OverwriteChange s. "
Anything I try to delete on the GridView gets the error. After trying a few different things with that, I looked around found some info that said to use the OnDeleted or OnDeleting for the Gridview and use SqlDataSourceEv entArgs for either of those, which allows for error handling.
When I tried it with OnDeleting I would just get an error saying there was no overload for those EventArgs. When I tried it with OnDeleted I would get no errors, but nothing would delete from the GridView.
I hope I have explained this clearly enough. Can anyone point me in the right direction?