Community
Showing results for 
Search instead for 
Do you mean 
Reply

Issues with binding Product fields to Winform Control

Copper Contributor
Posts: 123
Country: Canada

Issues with binding Product fields to Winform Control

[ Edited ]

Hey everyone,

I have created my own custom sub entity in the past and was able to bind the fields to my Winform controls all of the code I showed below is similar to how I did this and it worked great. (I was able to use aliases instead of realnames).

Now I am trying to do the same but for our Opportunity Products.

 

I am able to list all of the Opportunity Products in a datagridview without issue (unfortunatley can't use field alais for some reason).

 

My issue is that when I try to bind one of the fields to say a textbox control.  I get an exception error saying:

 

         Invalid name format: (the column name I passed in - tried alias, table.columnname , columnname)

         Parameter name: realName

 

I can't figure out why this won't work. If anyone could chime in on this it would be greatly appreciated as I've wasted a good few hours on this now.  Hoping that I don't have to create a whole new custom sub entity to achieve this as all of this worked fine on a normal created custom sub entity.

Thanks in advance for any help!
-Eric

 

 

//CustomSubEntityManager<OpportunityProduct> manager = actFwk.Products.OpportunityProductManager;
CustomEntityDescriptor descriptor = actFwk.CustomEntities.GetEntityDescriptor("PRODUCT_SERVICE");
CustomSubEntityManager<OpportunityProduct> manager = actFwk.CustomEntities.GetSubEntityManager<OpportunityProduct>(descriptor);

 

if (manager != null)
{
          // Get all the Products for the Current Opportunity.
          CustomEntityList<OpportunityProduct> oppProducts = tool.getOpportunityProducts(opp);
         

          if (oppProducts != null)
          {

                     string fieldName = "TBL_PRODUCTSERVICE.CUST_associatedContact_093035503"

                     oppProducts.FieldDescriptors.Add(manager.GetCustomEntityFieldDescriptor(fieldName, FieldNameType.Real));

 

                     // Set the data source of the binding source to be the list of doctorFees.
                     bindingSource1 = new BindingSource();
                     bindingSource1.DataSource = oppProducts;

                     // Databind the grid to the list of doctorFees.
                     this.dataGridView1.DataSource = bindingSource1;

 

                     textBox1.DataBindings.Add("Text", bindingSource1, "CUST_associatedContact_093035503", false);

          }

 

Bronze Super Contributor
Posts: 1,231
Country: USA

Re: Issues with binding Product fields to Winform Control

 

Have you tried the ACTDataMemberField instead of "CUST_associatedContact_093035503"?

 

It has been a while since I wrote our binding manager code but here is a wuick example:

 

Control.DataBindings.Add((New Windows.Forms.Binding(ACTPropertyName, Me.EntityBindingSource, ACTDataMemberField, False, DataSourceUpdateMode.OnValidation)))

 

 

-- Jim Durkin

Copper Contributor
Posts: 123
Country: Canada

Re: Issues with binding Product fields to Winform Control

I guess my alternative is to just not databind at all and save fields for current product manually....

Copper Contributor
Posts: 123
Country: Canada

Re: Issues with binding Product fields to Winform Control

I will just keep a reference to the current product something like this:

OpportunityProduct currentProd = oppProducts[0];

 

this.textBox1.Text = getFieldDescriptorByDisplayName("Associated Contact", manager).GetValue(oppProducts[0]).ToString();

It's a work around but hopefully it won't cause me too many issues.

Copper Contributor
Posts: 123
Country: Canada

Re: Issues with binding Product fields to Winform Control

Hey Jim, thanks I haven't tried that yet but I certainly will!

Your reply post didn't show up the day I posted the first message for some reason altough I get the email saying you replied.

I see your post now so I will certainly try that out.


Thanks again for the help!

-Eric