Datagridview data load is giving error

旧城冷巷雨未停 提交于 2019-12-25 05:27:22

问题


I have a datagrid that consists of 3 comboboxcolumns and 2 textboxcolumns. I am loading my datagridview with data from the dataset. The data loads with an error always at the first combobox column.for each row,it displays the error and continues the load without issues. Error is :

DataGridViewcomboboxcell value is not valid.To replace this default dialog please handle in the DataError event

Can anyone explain why I have this error and how to overcome it?

  sql = "Select  Sequence, ValueDate, AcctID, TransCode, DorC, Amount, Currency, Description1, Description2, LocalEquivalent From tempentries where FCID = " & mdi.Ids.Text & " and transid = " & TransID.Text
         da = New SqlDataAdapter(sql, UnauthCon)
    da.Fill(ds, "TempEntries")

    DGVTransactions.DataSource = ds.Tables("TempEntries")
               DGVTransactions.Refresh()

I just found one thing, the combobox is retrieving account numbers from the account table. I have set the combobox property as follows:

columnaclase.DisplayMember = "AccountNo"
        columnaclase.ValueMember = "AccName"

When I comment the valuemember code, the load works fine. Any idea why this is causing an error?

来源:https://stackoverflow.com/questions/17082721/datagridview-data-load-is-giving-error

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!