Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Combobox selected value return DataRowView

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
like image 607
Anand Thangappan Avatar asked Apr 08 '11 12:04

Anand Thangappan


1 Answers

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.

like image 86
Andrew Jens Avatar answered Oct 02 '22 00:10

Andrew Jens