Subject: Gridview Update Issue
Posted By: jpgregg Post Date: 9/1/2006 7:35:15 PM
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/Applications/Parts-Ordering/Admin/Admin.aspx?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

Go to topic 48573

Return to index page 186
Return to index page 185
Return to index page 184
Return to index page 183
Return to index page 182
Return to index page 181
Return to index page 180
Return to index page 179
Return to index page 178
Return to index page 177