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

RESET COLUMN FORMAT AFTER DATA BINDING

Dear Sir,

1. How to Set Numeric Column Format in SFDATAGRid after binding the data.
I have one Column in Decimal format which want to convert it to Integer(Numeric) Format. Please reply me at the earliest.

2. In SFDATAGRID, how to change the column format from text to dropdown list after data binding ?

Please send me code for the same

Thanks
Deepak

1 Reply

JP Jagadeesan Pichaimuthu Syncfusion Team May 20, 2019 11:51 AM UTC

Hi Deepak, 
  
Thanks for using Syncfusion products. 
  
Query 
Solution 
I have one Column in Decimal format which want to convert it to Integer(Numeric) Format. Please reply me at the earliest. 
If you want to change the decimal format of the numeric column after assigning the datasource, you can use the NumberFormatInfo property of the numeric column. Refer to the following code snippet, 
  
Code Snippet: 
var decimalColumn = this.sfDataGrid1.Columns["UnitPrice"asGridNumericColumn; 
  
//Set the decimal digits as zero to display the numeric values. 
decimalColumn.NumberFormatInfo = newSystem.Globalization.NumberFormatInfo() { NumberDecimalDigits = 0 }; 
In SFDATAGRID, how to change the column format from text to dropdown list after data binding ? 
If you want to change the text column as combobox column after binding the datasource, you need to remove the existing text column from the Columns collection and add it as the ComboBox column. Refer to the following code snippet, 
  
Code Snippet: 
List<string> countries = new List<string>(); 
countries.Add("Austria"); 
countries.Add("Canada"); 
countries.Add("Brazil"); 
countries.Add("Argentina"); 
  
var columnIndex =this.sfDataGrid1.Columns.IndexOf(this.sfDataGrid1.Columns["ShipCountry"]); 
//Remove the existing text column in the given index. 
this.sfDataGrid1.Columns.RemoveAt(columnIndex); 
  
//Insert the combo box column at the given index. 
this.sfDataGrid1.Columns.Insert(columnIndex, new GridComboBoxColumn() { MappingName = "ShipCountry", DataSource = countries }); 
  
 
Let us know whether this helps also if you need any further assistance on this. 
  
Regards, 
Jagadeesan

Loader.
Up arrow icon