I have a column that is created programmatically and is set to a complex data type. I need the data type to be complex because I need to override the CompareTo method. I also want to be able to use textual filtering on this column, via the ToString() method of my type. When I try to filter on this column, a ParserException is thrown and my program crashes.
consider the following example:
class MyCellType
{
public string myName;
public string myParentName;
public override string ToString()
{
return myName;
}
public int CompareTo(Object obj)
{
//my compare function which sorts children underneath their parents...
if ( myParentName == ((MyCellType)obj)myParentName )
{
return String.Compare(myName, ((MyCellType)obj)myName);
}
else
{
return String.Compare(myParentName , ((AdminUnitCell)obj).myParentName );
}
}
}
//... code that initializes the grid and a data table
GridViewTextBoxColumn column = new GridViewTextBoxColumn();
column.Name = "MyColumn";
column.HeaderText = "MyColumn";
column.FieldName = "MyColumn";
column.DataType = typeof(MyCellType);
myGrid.MasterTemplate.Columns.Add(column);
myDataTable.Columns.Add("Title", typeof(MyCellType));
//...
myGrid.DataSource = myDataTable;
I looked for a solution to this problem but I could not find a definite answer. Is textual filtering possible on a complex data type via its ToString() method? If not, then can we get this feature (bug fix) in a future release? I find it difficult to believe that no has ever had a column with a complex data type on a filter-enabled grid and thus experienced the same crash that I am getting.
Any help would be appreciated.
consider the following example:
class MyCellType
{
public string myName;
public string myParentName;
public override string ToString()
{
return myName;
}
public int CompareTo(Object obj)
{
//my compare function which sorts children underneath their parents...
if ( myParentName == ((MyCellType)obj)myParentName )
{
return String.Compare(myName, ((MyCellType)obj)myName);
}
else
{
return String.Compare(myParentName , ((AdminUnitCell)obj).myParentName );
}
}
}
//... code that initializes the grid and a data table
GridViewTextBoxColumn column = new GridViewTextBoxColumn();
column.Name = "MyColumn";
column.HeaderText = "MyColumn";
column.FieldName = "MyColumn";
column.DataType = typeof(MyCellType);
myGrid.MasterTemplate.Columns.Add(column);
myDataTable.Columns.Add("Title", typeof(MyCellType));
//...
myGrid.DataSource = myDataTable;
I looked for a solution to this problem but I could not find a definite answer. Is textual filtering possible on a complex data type via its ToString() method? If not, then can we get this feature (bug fix) in a future release? I find it difficult to believe that no has ever had a column with a complex data type on a filter-enabled grid and thus experienced the same crash that I am getting.
Any help would be appreciated.