combobox.selectedvalue something is of type "System.Data.DataRowView"

  • Thread starter Thread starter AH
  • Start date Start date
A

AH

Hi, I am buzzled! if I set combobox.datasource to a dataview item (so that
it binds to a table), when I get return value from combobox.selectedvalue
SOMETIME error was returned bcos it is of type "system.data.datarowview" but
sometime it returns the value .... anyone could help?

Thank,

Albert
 
Try
' To put your failing code here and

Catch ex as exception

messagebox.show( ex.toString() )

End Try
 
Hi Albert,

Have you got any offending code to show us?

Regards,
Fergus
 
Come on MS, your news servers are still playing up. Messages are going
missing etc. Posts which were there an hour ago disappear.
 
One Handed Man said:
Come on MS, your news servers are still playing up. Messages are going
missing etc. Posts which were there an hour ago disappear.

All groups I have subscribed are working except this group...

:-(
 
-----Original Message-----
Hi Albert,

Have you got any offending code to show us?

Regards,
Fergus


.
hi Fergus,

I set the datasource for the combo(cmbTrmCde) to a
datatable (dt) at the form loading stage. when I check
for the selectvalue at the selectindexchange event, it
sometime throws error that it can't read b'cos it
is "System.Data.DataRowView" type. So I have to write the
additional codes to work around it by handling the
exception... I may have missed something that caused the
selectedvalue became "datarowview" type, any suggestion??

Rgds,

Albert


-------------- code --------------
Public Class FrmPymntrm
Dim dvTrm As New PymntLst
Dim dv As New DataView
Dim dt As New DataTable
Dim idx As Integer


#Region " Windows Form Designer generated code "
.....
Friend WithEvents cmbTrmCde As
system.Windows.Forms.ComboBox
......
#End Region

Private Sub FrmPymntrm_Load(ByVal sender As
System.Object, ByVal e As System.EventArgs) Handles
MyBase.Load
dv = dvTrm.IniPymnt
Dim dr As DataRow
dt = dv.Table()
cmbTrmCde.DataSource = dt
cmbTrmCde.DisplayMember = dvTrm.PymntDsp
cmbTrmCde.ValueMember = dvTrm.PymntVlM
End Sub

Private Sub cmbTrmCde_SelectedIndexChanged(ByVal
sender As System.Object, ByVal e As System.EventArgs)
Handles cmbTrmCde.SelectedIndexChanged
Dim SelCde As String
If cmbTrmCde.SelectedValue.GetType.ToString
= "System.Data.DataRowView" Then
Dim dv As DataRowView
dv = cmbTrmCde.SelectedValue
Idx = cmbTrmCde.SelectedIndex
SelCde = dv("PymntCode")
Else
SelCde = cmbTrmCde.SelectedValue
Idx = cmbTrmCde.SelectedIndex
End If
..... ...
End Sub
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Back
Top