开发者

Cannot get databinding to work

开发者 https://www.devze.com 2023-01-08 16:47 出处:网络
I am having difficulty binding to a property on my object. This is my property: private int? Tid; private int? innerTenantID {

I am having difficulty binding to a property on my object.

This is my property:

    private int? Tid;
    private int? innerTenantID { 
        get { return Tid; } 
        set { 
            Tid = value; 
            innerTenant = (value.HasValue)? Tenant.GetTenantByID(value.Value) : null;
        } 开发者_如何学JAVA
    }

And this is my attempt to bind:

        this.DataBindings.Add(new Binding("innerTenantID", tblCashReceiptsBindingSource, "TenantID"));

I get, ArguementException, "Cannot bind to the Property 'innerTenantID' on the target control. Prameter name: PropertyName;

The TenantID value is a nullable integer.


The first thing I see, is that the getter and setter is not public. Probably this is the problem.

    private int? Tid; 
    public int? innerTenantID {  
        get { return Tid; }  
        set {  
            Tid = value;  
            innerTenant = (value.HasValue)? Tenant.GetTenantByID(value.Value) : null; 
        }  
    } 
0

精彩评论

暂无评论...
验证码 换一张
取 消