private bool ShouldGenerateField(Type propertyType, GridView gridView) { if (gridView.RenderingCompatibility < VersionUtil.Framework45 && AutoGenerateEnumFields == null) { //This is for backward compatibility. Before 4.5, auto generating fields used to call into this method //and if someone has overriden this method to force generation of columns, the scenario should still //work. return(gridView.IsBindableType(propertyType)); } else { //If AutoGenerateEnumFileds is null here, the rendering compatibility must be 4.5 return(DataBoundControlHelper.IsBindableType(propertyType, enableEnums: AutoGenerateEnumFields ?? true)); } }
public void GridView_IsBindableType () { Type [] types = new Type [] { typeof(Boolean), typeof(Byte), typeof(Char), typeof(DateTime), typeof(Decimal), typeof(Double), typeof(Guid), typeof(Int16), typeof(Int32), typeof(Int64), typeof(SByte), typeof(Single), typeof(String), typeof(UInt16), typeof(UInt32), typeof(UInt64) }; GridView g = new GridView (); foreach (Type type in types) Assert.AreEqual (true, g.IsBindableType (type), type.ToString ()); Assert.AreEqual (false, g.IsBindableType (typeof (Enum)), "test"); Assert.AreEqual (false, g.IsBindableType (typeof (Object)), "test"); }
private bool ShouldGenerateField(Type propertyType, GridView gridView) { if (gridView.RenderingCompatibility < VersionUtil.Framework45 && AutoGenerateEnumFields == null) { //This is for backward compatibility. Before 4.5, auto generating fields used to call into this method //and if someone has overriden this method to force generation of columns, the scenario should still //work. return gridView.IsBindableType(propertyType); } else { //If AutoGenerateEnumFileds is null here, the rendering compatibility must be 4.5 return DataBoundControlHelper.IsBindableType(propertyType, enableEnums: AutoGenerateEnumFields ?? true); } }