DataBinding with DataRow - problems

I am currently coding a project under C # and am having problems. I will give a brief description of my form:

It has a datagridview in the bottom half of the form with a single row selection and read-only. In the upper half of the form, I have various components that are bound to the selected row in a datagridview. I did this because there were too many columns in the database to show in a datagridview without serious UI fading. This works fine, and the parsing format and events are raised correctly.

I have a โ€œAdd New Entryโ€ button that redirects controls in the upper half to a new datarow (which is not yet part of the data), and I am having problems with this. First, when binding directly to datarow, it seems that the controls are not happy with DBNull values, as they are bound to datatable. But thatโ€™s fine, I just set the default values โ€‹โ€‹for the new line before binding it. However, it seems that the Format and Parse events do not fire when they are connected for some reason directly on the line, and I cannot understand why? The main reason I need this is because the Date column of values โ€‹โ€‹should ideally be empty (empty from the point of view of the user interface), so I am setting DateTime.MinValue as the default value for the new row,and then I search for it in the / parse format and do meaningless conversions.

I assume that my main question is why datarow binding causes DBNull exceptions, when datatable binding with the same null values โ€‹โ€‹in the same columns does not raise an exception, and column restrictions have "Allow Nulls". My alternative question is: why don't Format / Parse events fire when the component is bound to datarow?

+3
source share
1 answer

, datagridview, , Googling , . , - DBNull, ?

.

(P.S. , , , , , , , , , )

+1

Source: https://habr.com/ru/post/1720649/


All Articles