DataGridView problem

Hi

I have a datagridview on a windows form. This form is filled via a BindingSource which binds a dataset to the control. The datagridview has 3 textcolumns and 2 comboboxcolumns. On scrolling I get a data error, the data is not updated on the datagridview. It loads without any problems but on scrolling many fields are blank and thus the error.

Could someone help me solve this problem

Thanks



Answer this question

DataGridView problem

  • Ducolino

    rkimble

    I get System.ArgumentException: DataGridComboCell value is not valid. I have a dataset containing 2 datatables with a datarelation between them. The second helps me show the options for the Combobox in the DataGrid. I use a bindingsource.

    The blank fields appear for sometimes one field and sometimes the whole datagrid has the same data. It is probably something to do with updating of the cells.

    Please let me know if you need any other info

    Thanks


  • cbcxcxzc

    Also you may want to check the order which the datasets are being populated. You want to populate the combobox items prior to populating the datagridview source. That way you know the combobox items are all there before you try binding to them.


  • Trond Undrum

    Do you get an actual exception If so, what does it say Or by error, do you just mean that the fields are blank but no error dialog is displayed

    What are the tables involved here I would assume that there are two tables with a relationship of some sort that provides the possible values for the comboboxes...

    Are the blank fields appearing on all 5 fields in a given record Is it only the TextBox fields or only the ComboBox fields



  • luca82

    I had the same suspicion that spotty has... The related "Table2" may not contain all of the values that Table1 is trying to display.

    This may not be a database issue however... The necessary records may indeed exist in Table2 on the database but they may not be getting filled into the DataSet. Check the Fill method that is being called for Table2 and ensure that there is no "Where" clause that my be reducing the values available.



  • xicogoes

    My guess would be that you trying to set the comboboxes with a value that doesn't exist in the comboboxes.

    I'll walk through a possible scenario which I've encountered before.

    So if you have a data set which lets say contained the following data

    John, London, 1
    Jill, NYC, 2
    Karen, Philadelphia, 2
    Gary, Milton Keynes, 1
    Katarina, Stockholm, 3

    It has 3 fields and the third field is the value of a different dataset used in the bindings for the combobox in the datagridview.

    But the dataset you use to populate the combobox contains the following Values

    1, Old
    2, Young

    This will cause the problem you are experiencing as there is nothing for a value of 3 in the dataset - in the possible values for the combobox and it will display a data error and display blank.

    So I would definately check the values being used to populate the possible values for the combobox and ensure that the dataset values are compatible with these values.


  • DataGridView problem