I can''t bind two columns to the same field?!

I was trying to bind two columns to the same field of my data source and got an error: "Item has already been added. Key in dictionary: 'XXXXAutoSizeMaxLength' Key being added: 'XXXXAutoSizeMaxLength'. XXXX being the name of the field.

What's going on?

1 Reply

RA Rajagopal Syncfusion Team September 4, 2007 01:38 AM UTC

Hi Stanley,

Thanks for your interest in Syncfusion Products.

The reason for this error is because you are trying to add a column that already exists in the TableDescriptor.Columns collection. That is, when you add the column to the TableDescriptor.Columns collection whose mapping name is same as the one in the columns collection. The default behvior in the latest version is to populate the column collection from the datasource and add any new entry to the end of the collection. When you bind two columns of same name to a field, this would result in this exception. Whereas, in older versions before you add anything to the collection, Columns.Clear() will be called internally. To avoid this error, you need to explicitly call the Clear() method before you add columns to the existing collection with same name.

Let me know if you have any other questions.

Regards,
Rajagopal

Loader.
Up arrow icon