Results 1 to 5 of 5

Thread: Dataview problems [resolved]

Threaded View

  1. #1

    Thread Starter
    Hyperactive Member
    Join Date
    Sep 2004
    Posts
    262

    Resolved Dataview problems [resolved]

    Okay, I have two combo boxes on a form, both displaying a different column from the same datatable, I want both these combo boxes to be sorted alphabetically though, so I created a dataview as so
    VB Code:
    1. ds.Tables.Add("ContactsCom")
    2. ddiView = New DataView(ds.Tables("ContactsCom"))

    I then bind the combo boxes as follows

    VB Code:
    1. Me.cbocompany.DataSource = ds
    2.         Me.cbocompany.DisplayMember = "ContactsCom.CompanyName"
    3.         Me.cbocompany.ValueMember = "ContactsCom.ContactID"
    4.  
    5.         ddiView.Sort = "MID"
    6.  
    7.         cboddi.DataSource = ddiView
    8.         Me.cboddi.DisplayMember = "MID"
    9.         Me.cbocompany.ValueMember = "ContactID"

    Which all seems to work fine, but my problem now is that on the
    cbocompany combo box this works
    VB Code:
    1. Private Sub cbocompany_SelectedIndexChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles cbocompany.SelectedIndexChanged
    2.  
    3.         Try
    4.  
    5.             MsgBox(cbocompany.SelectedValue)
    6.         Catch ex As Exception
    7.             MsgBox(ex.ToString)
    8.         End Try
    9.  
    10.     End Sub
    But on the cboddi box I get the exception

    VB Code:
    1. Private Sub cboddi_SelectedIndexChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles cboddi.SelectedIndexChanged
    2.        
    3.         Try
    4.             MsgBox(cboddi.SelectedValue)
    5.        
    6.         Catch ex As Exception
    7.             Me.TextBox1.Text = ex.ToString
    8.         End Try
    9.  
    10.     End Sub

    System.ArgumentException: Argument 'Prompt' cannot be converted to type 'String'.

    Why?
    Last edited by Oliver1; Feb 10th, 2006 at 06:51 AM. Reason: resolved

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width