I set combobox.datasource to a dataview item (so that it binds to a table), When I get return value from combobox.selectedvalue. Error was returned bcos it is of type "system.data.datarowview"
I don't know why commonly its return value as text
The code :
If ldstList.Tables(0).Rows.Count <> 0 Then
With CbStatus
.DataSource = ldstList.Tables(0)
.DisplayMember = "CardStatus"
.ValueMember = "StatusID"
End With
End If
If Integer.Parse(CbStatus.SelectedValue) > 0 Then
GridLoad(Integer.Parse(CbStatus.SelectedValue))
End If
Regardless of other issues or solutions, please make sure you set the properties of the ComboBox in the right order:
.DisplayMember = ...;
.ValueMember = ...;
.DataSource = ....; // Notice how this one is last?
Setting the DataSource property first will lead to "system.data.datarowview" issues.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With