This is a migrated thread and some comments may be shown as answers.

RadGridView when AutoGeneratingColumn Column.ItemType is null

4 Answers 89 Views
GridView
This is a migrated thread and some comments may be shown as answers.
W
Top achievements
Rank 1
W asked on 28 Apr 2016, 08:28 AM

RadGridView when AutoGeneratingColumn(Event or override OnAutoGeneratingColumn) Column.ItemType is null.

How can I get ItemType?

4 Answers, 1 is accepted

Sort by
0
Yoan
Telerik team
answered on 28 Apr 2016, 10:52 AM
Hello,

You can use ItemPropertyInfo argument of AutoGeneratingColumn event - args.ItemPropertyInfo.PropertyType .

I hope this helps.

Regards,
Yoan
Telerik
Do you need help with upgrading your AJAX, WPF or WinForms project? Check the Telerik API Analyzer and share your thoughts.
0
W
Top achievements
Rank 1
answered on 29 Apr 2016, 01:49 AM

Not PropertyType.

GridViewColumn.ItemType's summary : Gets the type of the item that the field belongs to.

GridView's items or ItemsSource is IEnumerable<T> or DataItemCollection or some type else.

How to get the item type "T" in AutoGeneratingColumn?

Is there any way to get "T" direct, not judge by GridView's items or ItemsSource?

0
Accepted
Yoan
Telerik team
answered on 03 May 2016, 02:58 PM
Hello,

I am afraid that you can not use the ItemType property of GridViewColumn in AutoGeneratingColumn. However, you can use the GridView's Items property. In fact, the GridViewColumn.ItemType property is using a similar approach:
/// <summary>
        /// Gets the type of the item that the field belongs to.
        /// </summary>
        /// <value>The type of the item.</value>
        public virtual Type ItemType
        {
            get
            {
                if (this.DataControl != null)
                {
                    return this.DataControl.Items.ElementType;
                }

However, ElementType is internal, so you can't use it directly.

Regards,
Yoan
Telerik
Do you need help with upgrading your AJAX, WPF or WinForms project? Check the Telerik API Analyzer and share your thoughts.
0
W
Top achievements
Rank 1
answered on 06 May 2016, 08:14 AM

Thank you for answer me!

But "ElementType" is not public.So that only judged indirectly.

Tags
GridView
Asked by
W
Top achievements
Rank 1
Answers by
Yoan
Telerik team
W
Top achievements
Rank 1
Share this question
or