We use cookies to give you the best experience on our website. If you continue to browse, then you agree to our privacy policy and cookie policy. Image for the cookie policy date

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 04:08 PM

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.
Live Chat Icon For mobile
Up arrow icon