无法绑定到新值成员。参数名称:value [英] Cannot bind to the new value member. Parameter name: value

查看:230
本文介绍了无法绑定到新值成员。参数名称:value的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

你好代码大师,



今天我一直在试图弄清楚这个问题。



我有一个组合框,里面装满了表A字段的值A

没有问题,我可以通过填写我的填充带有sql查询等的数据集。



现在的问题是,这个组合框还应该根据来自不同表的另一个组合框更改所选值,表B WHILE保留表A中的值以防万一他们想要将表A中的选定值更改为表B中的值。





I有这个代码从tableA中选择组合框的数据OnIndexChange,其中value = cmb1.value





在indexchange cmb1 =

Hello code masters,

Today I have been banging my head in the wall trying to figure this one out.

I have a combo box filled with values from table A field A
no issue on that, I am able to populate by filling my dataset with sql query and etc.

Now the problem is, this combo box should also change selected value based on another combo box coming from a different table, table B WHILE RETAINING THE VALUES FROM TABLE A just in case they wanted to change the selected value from table A to values from table B.


I have this code which selects data OnIndexChange of combo box from tableA where value = cmb1.value


On indexchange cmb1 =

Dim ds As DataSet = SQL.RecOnChange(ojConn, BG) - select Field1 from tableA where field1 = cmb1.value

ojConn.Close()
If ds.Tables(0).Rows.Count > 0 Then
    Dim DT As New DataTable()
    DT = ds.Tables(0)
    cmb2.DataSource = DT
    cmb2.DisplayMember = "Field1"
    cmb2.ValueMember = "Field1"



这用于在页面加载时使用值填充cmb2:


and this for populating the cmb2 with values on page load:

Dim ds As DataSet = SQL.PopcmbEquip(ojConn, BG) - sql statement : select field2 from tableB order by field 2

ojConn.Close()
If ds.Tables(0).Rows.Count > 0 Then
    Dim DT As New DataTable()
    DT = ds.Tables(0)
    cmb2.DataSource = DT
    cmb2.DisplayMember = "Field2"
   cmb2.ValueMember = "Field2"



我收到错误:


I am getting error:

Cannot bind to the new value member.  Parameter name: value



我认为错误是因为我无法将两个数据源和值成员分配给一个组合框:(



任何输入都将不胜感激。

提前非常感谢。


I think the error is because I cannot assign two datasource and valuemember to one combo box :(

Any inputs will be greatly appreciated.
Thank you so much in advance.

推荐答案

如果你想要两个SQL结果绑定在一个组合框中,只需使用带有select语句的UNION:



If you want both SQL results bound to one combo box, simply use a UNION with your select statements:

select Field1 from tableA where field1 = cmb1.value
UNION
select field2 from tableB order by field 2





这可以让你在一个你可以绑定的表中得到两个查询。



Brent



This should get you both queries in one table that you can bind to.

Brent


这篇关于无法绑定到新值成员。参数名称:value的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆