Hello all,
I have a web page that has a standard gridview control using an accessdatasource to pull all records from a database table. I have also added a custom hyperlink field that redirects the user to another page using the following datanavigateurlformatstring:" ~/Private/Applications/Parts-Ordering/Admin/Manage.aspx?RequestID={0}"
This all works as expected and the new page opens and populates some text boxes by querying the DB for the row containing RequestID. Now here is where I have a problem. I have a button named delete that calls some code that deletes the DB row containing RequestID. The code is listed below. The delete command works as expected but when the code processes the "Response.Redirect(
http://wintelservices/Private/Applic...x?App=Requests)", I am taken back to the main page containg my gridview. The row with the RequestID is still in the gridview. If I press F5 a few times, it eventually disappears. I have tried disabling page cache and set the cachduration for the accessdatasource to 1 second, but it still happens every time. Any help would be appreciated. I assume that the server is caching the accessdatasource results but no matter what I change, the value still shows up. Thank you in advance.
Protected Sub btnDelete_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles btnDelete.Click
Dim strConnectionString As String = "Provider=Microsoft.Jet.OLEDB.4.0;" & _
"Data Source=D:\Inetpub\wwwroot\Private\Data\Parts-Tracking.mdb;"
Dim objConnection As New OleDbConnection(strConnectionString)
Dim objCommand As New OleDbCommand("usp_DeleteRequestByID", objConnection)
objConnection.Open()
objCommand.CommandType = CommandType.StoredProcedure
objCommand.Parameters.Add(New OleDbParameter("@REQUESTID", Page.Request.QueryString("REQUESTID").ToString))
If objCommand.ExecuteNonQuery() = 1 Then
Response.Redirect("http://wintelservices/Private/Applications/Parts-Ordering/Admin/Admin.aspx?App=Requests")
Else
Response.Write("There was an error deleting your request. Please try again.")
End If
End Sub
Jim Gregg