I am using VB.NET VS 2005 ..the problem is this...
I have a Combobox that is coded up this way on the Form Load event...
strSql = "SELECT lID,sDepotDesc From tDepot"
da = New SqlDataAdapter(strSql, con)
Dim dt As New DataTable
Dim drNewRow As DataRow
For Each drDSRow In ds.Tables("tDepot").Rows()
drNewRow = dt.NewRow()
drNewRow("lID") = drDSRow("lID")
drNewRow("sDepotDesc") = drDSRow("sDepotDesc")
cmbo_depot1.DropDownStyle = ComboBoxStyle.DropDownList
.DataSource = dt
.DisplayMember = "sDepotDesc"
.ValueMember = "lID"
.SelectedIndex = 0
I have a variable that holds the ID of the Depot when the ComboBox is changed ( which will be used to insert as part of a row in a table)...the problem is if you don't change the comboBox ...I get an error on the Insert statement because the Index hasn't changed
"The name "System.Data.DataRowView" is not permitted in this context"
this is the code that is supposed to capture the ID of the selection in the ComboBox...
Private Sub cmbo_depot1_SelectedIndexChanged(ByVal sender As Object, ByVal e As System.EventArgs) Handles cmbo_depot1.SelectedIndexChanged
lnPrivDepotID = cmbo_depot1.SelectedValue.ToString
Basically I need words displayed in the comboBox to force the user to change the combobox to pick a selection, so the index is changed .... I used the .SelectedText to do this but I still don't see the words as the firstSelction in the ComboBox..
I don't need to do it this way....I need to be able to grab the first selection in the combobox without actual changing the combobox...the user sees the first selection and sometimes doesn't change the selection and thus it throws an error..
Any help or insight would be much appreciated...