S
shawn.yu
When a certain line of code is called, a messagebox is displayed to the user
with the message "Conversion from type 'DataRowView' to type 'Integer' is not
valid.". The strange thing is that I am not telling a messagebox to be
displayed (I am not calling MessageBox.Show or anything similar). No
exception is thrown. The line of code is still executed successfully.
Here is the method:
Public Shared Sub PopulateMonthDropDown(ByVal cboMonth As ComboBox, ByVal
month As Integer)
Dim dt As DataTable = New DataTable("month")
dt.Columns.Add("monthcode", GetType(Integer))
dt.Columns.Add("monthstring", GetType(String))
dt.Rows.Add(New Object() {1, "January"})
dt.Rows.Add(New Object() {2, "February"})
dt.Rows.Add(New Object() {3, "March"})
dt.Rows.Add(New Object() {4, "April"})
dt.Rows.Add(New Object() {5, "May"})
dt.Rows.Add(New Object() {6, "June"})
dt.Rows.Add(New Object() {7, "July"})
dt.Rows.Add(New Object() {8, "August"})
dt.Rows.Add(New Object() {9, "September"})
dt.Rows.Add(New Object() {10, "October"})
dt.Rows.Add(New Object() {11, "November"})
dt.Rows.Add(New Object() {12, "December"})
cboMonth.DataSource = dt 'Message is dispalyed here
cboMonth.DisplayMember = "monthstring"
cboMonth.ValueMember = "monthcode"
cboMonth.SelectedValue = month
End Sub
As per the comment, the messagebox is displayed when I call
cboMonth.DataSource = dt. What can cause message boxes to be displayed
without directly telling them to?
with the message "Conversion from type 'DataRowView' to type 'Integer' is not
valid.". The strange thing is that I am not telling a messagebox to be
displayed (I am not calling MessageBox.Show or anything similar). No
exception is thrown. The line of code is still executed successfully.
Here is the method:
Public Shared Sub PopulateMonthDropDown(ByVal cboMonth As ComboBox, ByVal
month As Integer)
Dim dt As DataTable = New DataTable("month")
dt.Columns.Add("monthcode", GetType(Integer))
dt.Columns.Add("monthstring", GetType(String))
dt.Rows.Add(New Object() {1, "January"})
dt.Rows.Add(New Object() {2, "February"})
dt.Rows.Add(New Object() {3, "March"})
dt.Rows.Add(New Object() {4, "April"})
dt.Rows.Add(New Object() {5, "May"})
dt.Rows.Add(New Object() {6, "June"})
dt.Rows.Add(New Object() {7, "July"})
dt.Rows.Add(New Object() {8, "August"})
dt.Rows.Add(New Object() {9, "September"})
dt.Rows.Add(New Object() {10, "October"})
dt.Rows.Add(New Object() {11, "November"})
dt.Rows.Add(New Object() {12, "December"})
cboMonth.DataSource = dt 'Message is dispalyed here
cboMonth.DisplayMember = "monthstring"
cboMonth.ValueMember = "monthcode"
cboMonth.SelectedValue = month
End Sub
As per the comment, the messagebox is displayed when I call
cboMonth.DataSource = dt. What can cause message boxes to be displayed
without directly telling them to?