Still no success. And this problem is starting to spread through the new forms added to my project...it really sux.
Anyway, thank you TPM, for your advice and patience and if anyone could figure out, what's going on there, it would be greatly appreciated.
With tmp.Rows.InsertAt(row, 0) I'm trying to insert an empty item at the begining of the combo list, after the data binding's been created. The combination of putting the empty item at the position 0 and subsequently setting the SelectedValue to 1 seems to trouble vb.net and causes the error...
I found also another thing. If I change the statement
tmp.Rows.InsertAt(row, 0)
to
tmp.Rows.InsertAt(row, 1)
everything works fine, i.e. every position is OK except for the topmost one.
I have a dozen comboboxes bound like this accross the whole project, but this is the only one causing trouble. I tried to use a datatable with no success - here's the code:
Dim tmp as new DataTable
m_SqlCommand.CommandText = "SELECT tbl.Name, tbl.Id FROM tbl;"
m_DataAdapter.SelectCommand =...
Yeah, it's an int. I tried to delete the whole table and recreate it. After I'd inserted the first three rows, everything was fine. After inserting the fourth row, the lousy error came up again.
No, I don't have any event handler for the combo defined. I found out the following: if I delete the row with Id=5 from the database table, everything works fine. If I then add a new row to the table, the problem occurs again no matter what kind of data it contains.
I was doing basically the same thing, but I was setting r.item("ID") to DBNull.Value. I tried it with -1, but still no success.
This is the whole code:
m_SqlCommand.CommandText = "SELECT tbl.Name, tbl.Id FROM tbl;"
m_DataAdapter.SelectCommand = m_SqlCommand
m_DataAdapter.Fill(m_DataSetSys...
I'm using a combobox with the property DropDownStyle set to DropDownList. The combo is data-bound to a dataset with two colums: ID, Name and it contains the following records:
ID Name
1 A
2 B
3 C
5 D
The DisplayMember property is mapped to "Name" column and the ValueMember property...
This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
By continuing to use this site, you are consenting to our use of cookies.