Rebinding GridView using LinqDataSource

gridviewlinqlinqdatasource

I have a gridview that is using a LinqDataSource for it's datasource. I've added a FooterTemplate so users can insert new records. The Add Button has a command name that puts the values in a Dictionary list and then calls the LinqDataSource.Insert() method. This works fine. But the gridview never refreshes automatically with the new row. I'm using the LinqDataSource.Selecting event to initially bind the data. I've tried LinqDataSource.Bind() and GridView.Bind() but the gridview is never refreshed. Any idea how to get the GridView to rebind?

Note: I'm not using an UpdateDate panel, simple postback/refresh no ajax

Best Answer

Once solution that worked was to:

  • Add logic to define DataSourceID for GridView in CodeBehind
  • Call function after Insert() method
Related Topic