G
Guest
When using a datagridview, which contains one DataGridViewComboBoxColumn, I
get an error (System.FormatException: DataGridViewComboBoxCell value is not
valid), which has something to do with the databinding.
Situation:
I create a tabledef:
Dim dt As DataTable
dt = New DataTable(TABELDISPLAY)
dt.Columns.Add("CostplanID", GetType(Long))
dt.Columns.Add("CosttypeID", GetType(Long))
gDatasetDisplay.Tables.Add(dt)
I fill it:
For Each MyRow As DataRow In gdbProject.Costplan.GetRows()
dr = gDatasetDisplay.Tables(TABELDISPLAY).NewRow()
dr("CostplanID") = gdbProject.Costplan.CostplanID(MyRow)
dr("CosttypeID") = gdbProject.Costplan.GetCosttypeID(CostplanID)
gDatasetDisplay.Tables(TABELDISPLAY).Rows.Add(dr)
Next
MyDataView = New DataView(gDatasetDisplay.Tables(TABELDISPLAY), "", "",
DataViewRowState.CurrentRows) '"[MilestoneID]=" & MilestoneID & " AND
[PartnerID]=" & PartnerID
MyDataGridView.DataSource = MyDataView
I add a combo to the list, which should be linked to CosttypeID
Dim List As New DataGridViewComboBoxColumn()
List.HeaderText = "Costtype"
List.DataPropertyName = "CosttypeID"
DBProgram.Costtype.GetCosttypes(List)
.Columns.Add(List)
This however does not seem to work. What am I doing wrong???
The odd thing however, If I use the following code (which I do not WANT to
use), it shows the combobox without the error!:
gDatasetDisplay = New DataSet
Dim MyDBLink As New DBLink(DBProgram.GetConnectionString, QUERYDISPLAY,
TABELDISPLAY)
MyDBLink.OpenRecordset(gDatasetDisplay)
MyDBLink.Dispose()
MyDataView = New DataView(gDatasetDisplay.Tables(TABELDISPLAY), "", "",
DataViewRowState.CurrentRows) '"[MilestoneID]=" & MilestoneID & " AND
[PartnerID]=" & PartnerID
MyDataGridView.DataSource = MyDataView
get an error (System.FormatException: DataGridViewComboBoxCell value is not
valid), which has something to do with the databinding.
Situation:
I create a tabledef:
Dim dt As DataTable
dt = New DataTable(TABELDISPLAY)
dt.Columns.Add("CostplanID", GetType(Long))
dt.Columns.Add("CosttypeID", GetType(Long))
gDatasetDisplay.Tables.Add(dt)
I fill it:
For Each MyRow As DataRow In gdbProject.Costplan.GetRows()
dr = gDatasetDisplay.Tables(TABELDISPLAY).NewRow()
dr("CostplanID") = gdbProject.Costplan.CostplanID(MyRow)
dr("CosttypeID") = gdbProject.Costplan.GetCosttypeID(CostplanID)
gDatasetDisplay.Tables(TABELDISPLAY).Rows.Add(dr)
Next
MyDataView = New DataView(gDatasetDisplay.Tables(TABELDISPLAY), "", "",
DataViewRowState.CurrentRows) '"[MilestoneID]=" & MilestoneID & " AND
[PartnerID]=" & PartnerID
MyDataGridView.DataSource = MyDataView
I add a combo to the list, which should be linked to CosttypeID
Dim List As New DataGridViewComboBoxColumn()
List.HeaderText = "Costtype"
List.DataPropertyName = "CosttypeID"
DBProgram.Costtype.GetCosttypes(List)
.Columns.Add(List)
This however does not seem to work. What am I doing wrong???
The odd thing however, If I use the following code (which I do not WANT to
use), it shows the combobox without the error!:
gDatasetDisplay = New DataSet
Dim MyDBLink As New DBLink(DBProgram.GetConnectionString, QUERYDISPLAY,
TABELDISPLAY)
MyDBLink.OpenRecordset(gDatasetDisplay)
MyDBLink.Dispose()
MyDataView = New DataView(gDatasetDisplay.Tables(TABELDISPLAY), "", "",
DataViewRowState.CurrentRows) '"[MilestoneID]=" & MilestoneID & " AND
[PartnerID]=" & PartnerID
MyDataGridView.DataSource = MyDataView