Refresh data in ObjectDataSource in button event handler

I have a user control with GridView and  ObjectDataSource. I also have a button, that should update database and I wanted to refresh GridView in the same click callback.


And it’s easy to do- call ObjectDataSource.Select and then GridView.DataBind:


        Protected Sub btn1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btn1.Click


 ‘method to update database is omitted for simplicity


            Me.ObjectDataSource1.Select()


            Me.GridView1.DataBind()


        End Sub


Update: As I was adviced by Bob Riley, call to GridView1.DataBind()is enough.  

Advertisements