The relationship between foreground display and background data changes in C # for "Controls like GridView"

Source: Internet
Author: User

Recent controls, such as Dev's Treelist,gridcontrol, which show that data need to be bound to data sources such as a DataTable, and that the manager wants to change the content at any time, has just started to constantly refresh the controls, Updating the data source of the control (I need to fetch the data from the database here) is particularly troublesome.

These two days when I changed the code, I found some very quick places to talk about:

※ My data sources are all made in a DataTable.

1, when the data is fetched from the database and given to the DataTable, then as long as the database is no longer connected, all operations on the DataTable will not affect the data in the database.

2. After the DataTable obtained in the previous step is bound to the control's data source (assuming the treelist control), all changes made to the Treelist control in the window interface, such as changing the name of the node, the position of the mobile node, etc. Will react directly to the DataTable it binds to, while we make changes to a row of data in the DataTable (instead of re-fetching the data from the database), you do not need to refresh the treelist control to directly react to the data changes you have made to the interface. "What this means is that at the front desk, we can manipulate the controls and change the various places, and then the changes will react in real-time to the DataTable in which it is bound, so we can take the real-time changed data, so that we could do something else."

3, the database updates. Knowing the real-time update feature of the DataTable, after we have done all the changes to the control, we make a separate database connection and update the DataTable data into the database to achieve the consistency of the pre-and post-data.

4. After the data is bound to the foreground control GridView by using a DataTable, if the data relationship in the DataTable is changed in code, "This means that a child table relationship has been added to the GridView", Only the structure of the control is refreshed (Refreshdatasource only) to display the updated part.

5. Here I use the GridView control's child table to illustrate:

My process is to dynamically bind the data to the GridView, while in the code through the firing of events for the GridView to open the child table function, and then bind the data. While the data source is refreshed, the control does not immediately display the comparison in the "plus" of the child table:

In this case, only the structure of the GridView should be refreshed to show that the other refresh methods of the control will not work, I adopt the Refresh structure method is: GridView. Bestfitcolumn (), which enables instant changes to the data source while instantly refreshing the display.

The relationship between foreground display and background data changes in C # for "Controls like GridView"

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.