Ticket T347616
Visible to All Users

GridView don't refresh after change the datasource

created 9 years ago (modified 9 years ago)

I have a "empty" grid on a form.
Behind a button "Load", I query data from a MS SQL server in a datatable and then assign the datatable to the grid and do some formatting to the columns (set width, titles, datetime formats and so on.

This works fine, as long as I only query the same data (datatable / datafields)
But as soon as I change the datasource (same datatable name but more fields, the Grid / Gridview don't refreshes (don't show the additional rows)!
If I query the datatable with the additional fields first, the grid shows the additional fields correct.
The problem is, that the grid don't refresh the layout, if it was showed with the "small" datatable first and the the datasource is changed to the "big" datatable (with more fields).

Exactly what another user has noted here a long time ago (was marked as bug):
  https://www.devexpress.com/Support/Center/Question/Details/B190858

I have tried:
GridErgebnisanzeige.DataSource = Nothing
GridErgebnisanzeige.DataSource = Ergebnis
 GridView1.LayoutChanged()
GridView1.RefreshEditor(True)
GridErgebnisanzeige.PerformLayout()
 GridErgebnisanzeige.RefreshDataSource()
 GridView1.RefreshData()
Nothing works… :-(

How to refresh the Grid/Gridview (data and layout) after change the datasource  (same datable name but more fields / columns)?

Thanks

Answers approved by DevExpress Support

created 9 years ago (modified 9 years ago)

Hello,

To accomplish this task, you can use the approach from the How to properly assign a new datasource to a grid at runtime? KB article.
Try this approach and let us know if it works for you.
I am looking forward to your reply.

    Comments (3)

      Hi

      Thanks for your replay
      GridView1.Columns.Clear()

      seems to do the job :-)

      Nadezhda (DevExpress Support) 9 years ago

        I am glad to hear that the issue has been resolved. If you need further assistance, please let me know.

          Additional information (for other users)
          You only have to call:
          GridView1.Columns.Clear()
          and set the datasource to the new queried datatable (nothing else like I have tried in my first posting)

          So… I have started about a week ago to use DevExpress…
          I had some problems first (see my other postings) and the descriptions could be better (more practical examples!)

          But… overall… I can say - wow (DevExpress is worth the price no question) !

          Ans also the DevExpress support seems to be responsive :-)

          I'm happy now with DevExpress…

          Thanks to support (in common)
          Greetings from Switzerland

          Disclaimer: The information provided on DevExpress.com and affiliated web properties (including the DevExpress Support Center) is provided "as is" without warranty of any kind. Developer Express Inc disclaims all warranties, either express or implied, including the warranties of merchantability and fitness for a particular purpose. Please refer to the DevExpress.com Website Terms of Use for more information in this regard.

          Confidential Information: Developer Express Inc does not wish to receive, will not act to procure, nor will it solicit, confidential or proprietary materials and information from you through the DevExpress Support Center or its web properties. Any and all materials or information divulged during chats, email communications, online discussions, Support Center tickets, or made available to Developer Express Inc in any manner will be deemed NOT to be confidential by Developer Express Inc. Please refer to the DevExpress.com Website Terms of Use for more information in this regard.