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

Custom ObjectDataSource caused controls to stop working

2 Answers 57 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Øyvind Skaar
Top achievements
Rank 1
Øyvind Skaar asked on 28 Jan 2010, 03:25 PM
this one took me some time to figure out, but I am at a loss to understand what is happening.
I created the following class:
    /// <summary> 
    /// A data control to reference a method in the current page instance. 
    /// </summary> 
    public class PageMethodDataSource:ObjectDataSource 
    { 
        public PageMethodDataSource() 
        { 
            ObjectCreating += OnObjectCreating; 
        } 
        protected override void OnInit(System.EventArgs e) 
        { 
            base.OnInit(e); 
            TypeName = Page.GetType().BaseType.ToString(); 
        } 
 
        void OnObjectCreating(object sender, ObjectDataSourceEventArgs e) 
        { 
            e.ObjectInstance = Page; 
        } 
    } 

The purpose of this is to use methods in the page instance as data source for controls (in this case a RadGrid). This caused the web resource to stop loading, causing datepickers, timepickers etc to stop working (and the dreaded "Sys is not defined" and "Telerik" is not defined" javascript errors).
Can anyone spot what I may have violated to cause this behaviour?


2 Answers, 1 is accepted

Sort by
0
Tsvetoslav
Telerik team
answered on 03 Feb 2010, 08:43 AM
Hi Øyvind,

The information is to scarce to pinpoint the problem, however, I think you should not be setting:
e.ObjectInstance = Page, as the ObjecInstance holds the business object upon which data operations are performed and Page is no object of that kind.

If the issue persists, please, open up a formal support ticket, send a small sample with the problem reproduced in it and give more details on the latter.

Best wishes,
Tsvetoslav
the Telerik team

Watch a video on how to optimize your support resource searches and check out more tips on the blogs.
Follow the status of features or bugs in PITS and vote for them to affect their priority.
0
Øyvind Skaar
Top achievements
Rank 1
answered on 18 Feb 2010, 02:31 PM
Well, the whole point of the class was really to enable using properties in the Page class as the datasource.
Tags
Grid
Asked by
Øyvind Skaar
Top achievements
Rank 1
Answers by
Tsvetoslav
Telerik team
Øyvind Skaar
Top achievements
Rank 1
Share this question
or