How to Refresh GridView after Update on DetailsView

When using a master GridView with a details DetailView and an Insert or Update is performed at the DetailsView level the GridView does not refresh with the new values.  This one was bugging me for a while, but I finally found the answer. I knew that is was to do with the DataBind() on the GridView, but where and when did it need to be called.  The answer is to put the DataBind() on the DetailView’s  ItemUpdated  event.

  Private Sub DetailsView1_ItemUpdate(ByVal sender As Object, _
                                      ByVal e As DetailsViewUpdatedEventArgs) Handles DetailsView1.ItemUpdated
    GridView1.DataBind()
  End Sub

Technorati Tags: ,,
Advertisements

4 Responses to How to Refresh GridView after Update on DetailsView

  1. Joel says:

    Thank you! Finally a decently clear post on how to do this. I’ve seen way too many other posts that somehow manage to complicate it.

  2. Matt Bell says:

    You’re welcome 🙂

  3. Drew says:

    Joel’s comment seconded; your solution is concise and effective. Thanks!

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: