Adf.Web.UI.BusinessGridViewColumnTooltip.ItemDataBinding C# (CSharp) Method

ItemDataBinding() private method

private ItemDataBinding ( object sender, EventArgs e ) : void
sender object
e System.EventArgs
return void
        private void ItemDataBinding(object sender, EventArgs e)
        {
            var cell = sender as TableCell;
            if (cell == null)
                return;

            var item = cell.NamingContainer as GridViewRow;
            if (item == null || item.DataItem == null) return;

            //            PropertyInfo pi = item.DataItem.GetType().GetProperty(dataField);
            //            if (pi == null)
            //                return;
            //
            //            object val = pi.GetValue(item.DataItem, null);

            object val = PropertyHelper.GetValue(item.DataItem, DataField);

            if (val is Enum)
            {
                cell.Text = val.ToString();
                cell.ToolTip = (val as Enum).GetDescription();
            }
            else if (val is DateTime?)
            {
                var dateTime = val as DateTime?;

                var format = StateManager.Settings.Has("DateFormat")
                                 ? StateManager.Settings["DateFormat"].ToString()
                                 : CultureInfo.CurrentUICulture.DateTimeFormat.ShortDatePattern;

                cell.Text = dateTime.Value.ToString(format, CultureInfo.CurrentUICulture);
            }
            else if (val is bool?)
            {
                var value = val as bool?;

                cell.Text = (value.Value) ? "<input id='chkBool' type='checkbox' name='chkBool' checked disabled />" : "<input id='chkBool' type='checkbox' name='chkBool' disabled />";
            }
            else if (val is DomainObject)
            {
                cell.Text = val.ToString().BreakLongWords();
                if (!string.IsNullOrEmpty(DescriberField))
                {
                    object descriptionfield = PropertyHelper.GetValue(val, DescriberField);
                    if (descriptionfield != null) cell.ToolTip = descriptionfield.ToString();
                }
            }
            else if (val is IFormattable)
            {
                cell.Text = ((IFormattable)val).ToString(null, CultureInfo.CurrentUICulture);
            }
            else
            {
                cell.Text = (val == null) ? string.Empty : val.ToString().BreakLongWords();
            }
        }