Invalid DataGridViewComboBoxCell column values in VS2015 and workarounds for data binding errors DataGridView

Source: Internet
Author: User

Practice the use of DataGridView in VS2015,

A hint that an invalid value occurred after binding a database column exists in the DataGridViewComboBoxCell column

According to the online solution, add the DataError can solve the problem, but the database column is still not bound properly

After studying it, we finally understand the cause of the error and find a solution:

The DataGridViewComboBoxCell column is bound to the data that exists in the column item, otherwise it will be considered an error value, so be sure to populate the column's item before setting the DataPropertyName value of the column, or set the column's binding data in advance. The DataPropertyName value is set at the end, and the same is true in the designer, because the designer's datapropertyname is in front of the data binding.

So the correct solution is to bind the data when the form is loaded, and then set the DataPropertyName.

Error:

Correct method:

Invalid DataGridViewComboBoxCell column values in VS2015 and workarounds for data binding errors DataGridView

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.