Nullable is a new type added by ASP. net2.0 and can be simply described as a generic structure. It does not work for the dynamic Assignment Method in the previous chapter of this result. First, you must determine whether it is a generic and void type. Then retrieve the original type and assign values.
CodeAs follows:
System. reflection. propertyinfo = T. getproperty (VaR as testtextbox). Id );
If (propertyinfo! = NULL)
{
Bool isnullablevaluetype = propertyinfo. propertytype. isgenerictype & (propertyinfo. propertytype. getgenerictypedefinition () = typeof (nullable <> ));
Type generictype = propertyinfo. propertytype;
If (isnullablevaluetype)
Generictype = propertyinfo. propertytype. getgenericarguments () [0];
String temptext = (VaR as testtextbox). text;
If (! String. isnullorempty (temptext ))
Propertyinfo. setvalue (entity, convert. changetype (temptext, generictype), null );
}
Where
Isgenerictype determines whether it is generic
Getgenerictypedefinition () gets the definition of the Generic Structure