Hi,
I have a GridView that is unbound. I manually add the rows and the columns, one of which is a GridViewComboBoxColumn (other columns omitted):
_departments is a list containing a number of Department objects, which have among other things a Name property and an Id property.
I manually add the rows to the grid like this (still, other columns omitted):
I would like this to result in a new row in the grid, where "Department A" is selected in the list of values in the GridViewComboBoxColumn. However, this doesn't work. Trying to set the name results in a FormatException ("Input string was not in a correct format.")
I feel silly for having to ask because it must be dead simple, but I am stuck!
Best regards
I have a GridView that is unbound. I manually add the rows and the columns, one of which is a GridViewComboBoxColumn (other columns omitted):
var departmentColumn = new GridViewComboBoxColumn();departmentColumn.HeaderText = "Department";departmentColumn.Name = "departmentColumn";departmentColumn.Width = 120;departmentColumn.DisplayMember = "Name";departmentColumn.ValueMember = "Id";departmentColumn.DataSource = _departments;grid.MasterTemplate.Columns.AddRange(new GridViewDataColumn[] { departmentColumn });_departments is a list containing a number of Department objects, which have among other things a Name property and an Id property.
I manually add the rows to the grid like this (still, other columns omitted):
var row = grid.Rows.AddNew();row.Cells[0].Value = "Department A";I would like this to result in a new row in the grid, where "Department A" is selected in the list of values in the GridViewComboBoxColumn. However, this doesn't work. Trying to set the name results in a FormatException ("Input string was not in a correct format.")
I feel silly for having to ask because it must be dead simple, but I am stuck!
Best regards
