Reputation: 33850
I bind my ASP.NET 2.0 GridView control to a datasource at design time in the Visual Designer.
If the database changes, how do I update the GridView control to reflect the changes in the database?
If the grid was programmatically data-bound, I could have got a fresh copy of data and rebound.
Update
I think I need to clarify my question further. If my GridView
was bound at design time using a SqlDataSource
data control, then how do I update the GridView
programmatically? Do I bind it to a new DataSet
or do I simply call the GridView.DataBind()
method without changing its data source?
I think I tried this in between and simply calling the GridView.DataBind()
did it, but I can't be sure.
Upvotes: 0
Views: 1079
Reputation: 109
You can use AJAX to implement same. Place your GridView in a Update Panel. Add a timer and on timer tick you can rebind your Gridview. As soon as, data is changed in database it is reflected in the gridview with the tick of timer.
Upvotes: 3
Reputation: 4803
There isn't a built in way to do this in .Net that I've seen.
I believe the best thing you can do is create a data-update thread that checks for new Db values periodically and re-binds the grid from the code-behind as necessary
Upvotes: 1