Type Conversion.

I have a GriddataboundGrid control which displays the property of some class in the read only fashion. One property in the class is of type "int" which I would like to display as a string inside the Grid ( Example: 1 - America, 2 - Europe etc. ). I try to decorate the particular property with the: [TypeConverter(typeof(MyConverterClass))] attribute to do the conversion for me. This works for the .NET native controls but in the case of the GridDataBoundGrid the conversion does NOT happend. Does the Syncfusion GridDataBoundGrid use this type of attribute for conversion? What other mechanisms can I employ to do the necessary conversion for me.

1 Reply

AD Administrator Syncfusion Team June 4, 2004 08:08 PM UTC

I will have to check to see whether the typeconverter attribute should be picked up by our grid. One way you can do this is create a DataTable with 2 columns, DisplayMember and ValueMember (or create an arraylist of objects where the object have properties DisplaMember and ValueMember). For the displaymember, use the text you want to see. For the valuemember, set the integer value. You can then set GridStyleInfo style = this.grid.Binder.InternalColumns["Col1"].StyleInfo; style.DataSource = MyDataTable; //or arraylist style.DisplayMember = "DisplayMember"; style.ValueMember = "ValueMember"; style.ShowButtons = GridShowButtons.Hide;

Loader.
Up arrow icon