AspNetEdit.UI.PropertyEditors.StringEditor.entry_Changed C# (CSharp) Method

entry_Changed() public method

public entry_Changed ( object sender, EventArgs e ) : void
sender object
e System.EventArgs
return void
        void entry_Changed(object sender, EventArgs e)
        {
            //Catching all exceptions is bad, but converter can throw all sorts of exception
            //with invalid entries. We just want to ignore bad entries.
            string text = ((Entry) sender).Text;
            try {
                //if value was null and new value is empty, leave as null
                if (!(text == "" && parentRow.PropertyValue== null))
                    parentRow.PropertyValue = parentRow.PropertyDescriptor.Converter.ConvertFromString (((Entry) sender).Text);
            }
            catch (Exception ex)
            {
                //we want to give a helpful error message: even if we ignore these exceptions
                //most of the time, the error may still be useful when debugging controls
                System.Diagnostics.Trace.WriteLine (
                    "PropertyGrid String Editor: TypeConverter could not convert string \"" + text +
                    "\" to " + parentRow.PropertyDescriptor.PropertyType.ToString () +
                    " for property \"" + parentRow.PropertyDescriptor.DisplayName + "\".\n" +
                    "Error details: "+ ex.Message
                );
            }
        }