• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 11288
  • Last Modified:

Gridview does not refresh after update to DetailsView

I have a gridview which allows me to show the details through a DetailsView server control.

The DetailsView allows updates and inserts. Whenever I update or insert a record through the DetailsView my GridView does not show the changes.

Is there a way to force the SQLDataSource or GridView to refresh?
0
SuperGhosty
Asked:
SuperGhosty
1 Solution
 
Pratima PharandeCommented:
Bind the data again to GridView after update or insert.
0
 
SuperGhostyAuthor Commented:
I tried clearing the datasource and datasourceid then rebinding to the SQLDataSource server control and it still does not show the changes.
0
 
SuperGhostyAuthor Commented:
I solved the problem,

for those who are having the same issue here is the diagnosis:

If you have a "Master - Details" set up with a gridview (master) and detailsview (details) and after inserting or updating in the detailsview the gridview does not update then you're calling the DataBind() in the wrong place. You should call the DataBind command on the DetailsView's "ItemUpdated" event. I believe the problem is the order of page events, if you call the databind after the update then it's too late and the gridview will not update.

    Protected Sub DetailsView1_ItemUpdated(ByVal sender As Object, ByVal e As System.Web.UI.WebControls.DetailsViewUpdatedEventArgs) Handles DetailsView1.ItemUpdated
        GridView1.DataBind()
    End Sub
0
 
NetminderCommented:
Closed, 125 points refunded.
Netminder
Site Admin
0
 
Nathan08Commented:
I was also having trouble with this, I fixed it by adding my unique field to the DataKeyName in the formview properites, it then updated the table.
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

Join & Write a Comment

Featured Post

Cloud Class® Course: CompTIA Cloud+

The CompTIA Cloud+ Basic training course will teach you about cloud concepts and models, data storage, networking, and network infrastructure.

Tackle projects and never again get stuck behind a technical roadblock.
Join Now