I have a gridDataBoundGrid wired to a gridFilterBar. To ensure that the comboboxes on the filterbar are sorted when clicked on, I have the following code:
for(int i = 0; i < grid.Model.ColCount; i++)
DataTable dt = grid[1, i].DataSource as DataTable;
if(dt != null)
string sortString = dt.Columns.ColumnName + " ASC";
dt.DefaultView.Sort = sortString;
The reason I need this code is because as rows are being added/deleted from the grid I update the filterbar combobox models are described in:
This works fine as long as the DataType for the columns these comboboxes are being used on are strings. I have some columns that are ints but when the values are added to the combobox model they are being added as strings and then the combo box is not sorted numerically. I can''t change the dataType as the (none) value needs to be displayed. Is there anyway I can get the combobox to sort numerically?
ADAdministrator Syncfusion Team November 8, 2004 04:10 AM
I do not know of a simple way to do this.
One possibilty is to add an extra column of typeof(int) to the combobox datatable. Then move the ints from your ''real'' column to this extra column. For the (none) and (custom) entires add some well-chosen int values that will put them in the correct places in your int sort order. Then sort the DataTable based on this extra hidden column.