组合框选择价值回归的DataRowView [英] Combobox selected value return DataRowView
本文介绍了组合框选择价值回归的DataRowView的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我设置combobox.datasource到数据视图项目(以便它绑定到一个表),当我从combobox.selectedvalue返回值。错误返回BCOS它的类型是system.data.datarowview
我不知道为什么常用的返回值作为文本
在code:
如果ldstList.Tables(0).Rows.Count<> 0然后
随着CbStatus
.DataSource = ldstList.Tables(0)
.DisplayMember =CardStatus
.ValueMember =StatusID
结束与
结束如果
如果Integer.Parse(CbStatus.SelectedValue)> 0然后
GridLoad(Integer.Parse(CbStatus.SelectedValue))
结束如果
解决方案
我不知道为什么这个问题就出现了。不过,我已经找到了解决办法:
如果Integer.Parse(DirectCast(CbStatus.SelectedItem,DataRowView的).Item(StatusID))> 0然后
GridLoad(Integer.Parse(DirectCast(CbStatus.SelectedItem,DataRowView的).Item(StatusID)))
结束如果
感谢那些谁回答,如果你有一千万张贴解释或更好的解决方案。
I set combobox.datasource to a dataview item (so that it binds to a table), When I get return value from combobox.selectedvalue. Error was returned bcos it is of type "system.data.datarowview"
I don't know why commonly its return value as text
The code :
If ldstList.Tables(0).Rows.Count <> 0 Then
With CbStatus
.DataSource = ldstList.Tables(0)
.DisplayMember = "CardStatus"
.ValueMember = "StatusID"
End With
End If
If Integer.Parse(CbStatus.SelectedValue) > 0 Then
GridLoad(Integer.Parse(CbStatus.SelectedValue))
End If
解决方案
I don't know why the issue arises. But I have found a solution:
If Integer.Parse(DirectCast(CbStatus.SelectedItem, DataRowView).Item("StatusID")) > 0 Then
GridLoad(Integer.Parse(DirectCast(CbStatus.SelectedItem, DataRowView).Item("StatusID")))
End If
Thanks to those who answered, and please do post an explanation or a better solution if you have one.
这篇关于组合框选择价值回归的DataRowView的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文