Telerik Forums
UI for ASP.NET AJAX Forum
4 answers
197 views
I am working on a project that would benefit from adding a RadGrid to a CompositeControl.  The grid works as expected until I attempt to handle the ItemCreated event which results in the following exception:  Unable to cast object of type 'Telerik.Web.UI.GridItemEventHandler' to type 'Telerik.Web.UI.GridItemEventHandler'.

I have submitted a Telerik support ticket requesting assistance with this exception and to see if there is a different way of doing what I need. Unfortunatly after several exchanges with support I have found myself stuck in a "it works for me" loop.

Is there anyone in the community who can see an issue with the way I have coded this CompositeControl or is there a better/different way to create a CompositeControl containing a RadGrid that handles events that I can test?

Thank you!

CustomControls.dll (The CompositeControl with RadGrid)
using System.ComponentModel; 
using System.Web.UI; 
using System.Web.UI.WebControls; 
using Telerik.Web.UI; 
 
namespace Company.CustomControls 
    [ToolboxData("<{0}:CustomGrid runat=server></{0}:CustomGrid>")] 
    public class CustomGrid : CompositeControl, INamingContainer 
    { 
        private RadGrid _MainGridView; 
 
        public CustomGrid() { 
            _MainGridView = new RadGrid(); 
        } 
 
        public object DataSource { 
            get { return _MainGridView.DataSource; } 
            set { _MainGridView.DataSource = value; } 
        } 
 
        protected override void CreateChildControls() { 
            Controls.Add(new LiteralControl("Custom Grid:<br />")); 
            _MainGridView.AutoGenerateColumns = true
            Controls.Add(_MainGridView); 
        } 
 
        public event GridItemEventHandler ItemCreated { 
            add { _MainGridView.ItemCreated += value; } 
            remove { _MainGridView.ItemCreated -= value; } 
        } 
    } 

Default.aspx
<%@ Page Language="C#" AutoEventWireup="true" CodeFile="Default.aspx.cs" Inherits="_Default" %> 
<%@ Register assembly="CustomControls" namespace="Company.CustomControls" tagprefix="cc1" %> 
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> 
<html xmlns="http://www.w3.org/1999/xhtml"
<head runat="server"><title>CustomGrid Test</title></head
<body> 
    <form id="form1" runat="server"
    <div> 
        <asp:ScriptManager ID="ScriptManager1" runat="server"
        </asp:ScriptManager> 
        <cc1:CustomGrid runat="server" ID="mainCustomGrid" onitemcreated="mainCustomGrid_ItemCreated"></cc1:CustomGrid> 
    </div> 
    </form> 
</body> 
</html> 

Default.aspx.cs
using System; 
using System.Collections.Generic; 
 
public partial class _Default : System.Web.UI.Page 
    protected void Page_Load(object sender, EventArgs e) 
    { 
        List<TestData> GridData = new List<TestData>(); 
        for (int i = 1000; i < 1025; i++) 
            GridData.Add(new TestData { Name = "Name " + i.ToString(), Phone = "555-555-" + i.ToString() }); 
        mainCustomGrid.DataSource = GridData; 
    } 
 
    protected void mainCustomGrid_ItemCreated(object sender, Telerik.Web.UI.GridItemEventArgs e) { 
        // Do work here... 
    } 
 
public class TestData 
    public string Name { getset; } 
    public string Phone { getset; } 

Exception
[InvalidCastException: Unable to cast object of type 'Telerik.Web.UI.GridItemEventHandler' to type 'Telerik.Web.UI.GridItemEventHandler'.]
   Telerik.Web.UI.RadGrid.OnItemCreated(GridItemEventArgs e) +110
   Telerik.Web.UI.RadGrid.CallOnItemCreated(GridItemEventArgs e) +39
   Telerik.Web.UI.GridItem.SetupItem(Boolean dataBind, Object dataItem, GridColumn[] columns, ControlCollection rows) +986
   Telerik.Web.UI.GridTableView.CreateHeaderItem(Boolean useDataSource, GridColumn[] copiedColumnSet, GridTHead thead) +126
   Telerik.Web.UI.GridTableView.CreateControlHierarchy(Boolean useDataSource) +980
   Telerik.Web.UI.GridTableView.CreateChildControls(IEnumerable dataSource, Boolean useDataSource) +802
   System.Web.UI.WebControls.CompositeDataBoundControl.PerformDataBinding(IEnumerable data) +57
   System.Web.UI.WebControls.DataBoundControl.OnDataSourceViewSelectCallback(IEnumerable data) +114
   System.Web.UI.DataSourceView.Select(DataSourceSelectArguments arguments, DataSourceViewSelectCallback callback) +31
   System.Web.UI.WebControls.DataBoundControl.PerformSelect() +142
   Telerik.Web.UI.GridTableView.PerformSelect() +28
   System.Web.UI.WebControls.BaseDataBoundControl.DataBind() +73
   Telerik.Web.UI.GridTableView.DataBind() +368
   Telerik.Web.UI.RadGrid.DataBind() +165
   Telerik.Web.UI.RadGrid.AutoDataBind(GridRebindReason rebindReason) +3855
   Telerik.Web.UI.RadGrid.OnLoad(EventArgs e) +177
   System.Web.UI.Control.LoadRecursive() +50
   System.Web.UI.Control.AddedControl(Control control, Int32 index) +265
   System.Web.UI.ControlCollection.Add(Control child) +80
   Company.CustomControls.CustomGrid.CreateChildControls() in C:\Data\CompositeControlGrid\TelerikTesting\CustomControls\CustomGrid.cs:28
   System.Web.UI.Control.EnsureChildControls() +87
   System.Web.UI.Control.PreRenderRecursiveInternal() +44
   System.Web.UI.Control.PreRenderRecursiveInternal() +171
   System.Web.UI.Control.PreRenderRecursiveInternal() +171
   System.Web.UI.Page.ProcessRequestMain(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint) +84




RKemp
Top achievements
Rank 1
 answered on 16 Jan 2009
2 answers
104 views
Hi,

I just installed the new "aspnet video" controls and realised that all my telerik controls diasappeared from the toolbox. Is it a bug? How can I get the controls back in my tool box?


Thanks,
Ketan
ketan reddy
Top achievements
Rank 1
 answered on 16 Jan 2009
0 answers
86 views
hi

I have 4 pages in my website and iam uploading a file using rad controls in 2nd page and im redirected to 3rd page....if i want to go back to 2nd page again using "back screen" then iam getting "Webpage expired" message... and if i refresh the 2nd page  again, then im getting the values... What could be the reason?

any idea?????

thanks in advance

vijay
vijay
Top achievements
Rank 1
 asked on 16 Jan 2009
4 answers
158 views
Hi,

I want to know how and where the MOSS RAD Editor content will be stored?Will RAD Editor maintain any own database or will it be stored in MOSS content database ? Will it maintain versions?


Thanks,
Surya

Stephen Heverin
Top achievements
Rank 2
 answered on 16 Jan 2009
4 answers
173 views
Is there a way that when I click on the text of a node in edit mode, it is not taken out of edit mode?

I've tried to retrieve the node as a DOM input object in EditStart handler, move this input object to outside the anchor object, and in EditEnd put it back after edit is finished -- but it led to some problems, and in one major browser the input element lost focus after I first moved it.

Thanks,
Fredrik
Mallverkstan
Mallverkstan
Top achievements
Rank 2
 answered on 16 Jan 2009
3 answers
343 views
Hi,

   Good day, i want to hide the entire toolbar on radeditor, my first solution is i created a blank.xml which consist only of <root></root> and point the toolsfile to blank.xml, this works in IE, but in firefox, it hangs, how can i achieve this behaviour? tnx
Rumen
Telerik team
 answered on 16 Jan 2009
2 answers
102 views
Is there a way to avoid the page refresh when the edit link on a row is clicked and the MasterTemplateEditForm is shown?
Reid
Top achievements
Rank 2
 answered on 16 Jan 2009
2 answers
91 views
Is there a way to produce a header area (non scrolling area) within a radpanel?
Michael
Top achievements
Rank 1
 answered on 16 Jan 2009
5 answers
210 views
Hello,

i need some help. 
I am using the RadEditor for SharePoint in a WCM Cenario, the Version is 4.3.1.0.

I need to add some special Company-Specific-colors into the color picker (The small window you can change the background or font color). 

Can anybody help me?

Thx Marco


Marja
Top achievements
Rank 1
 answered on 16 Jan 2009
1 answer
87 views
I am trying to use the RadEditor as an in-place editor for sections of a HTML page by using several radeditor controls on the same page. One control for each editable part of the page.

The problem I have is that whenever the editor controls are 'enabled', a 1px black border is showing around the text.

How can I get rid of this border? I haven't been able to identify which CSS class for the control is creating this border.

My code is exactly like your demo for 'using RadEditor as a textbox' (http://demos.telerik.com/aspnet-ajax/Editor/Examples/EditorAsTextBox/DefaultCS.aspx), except that I don't want a border on the text box.

I hope somebody can help. Thanks in advance.
Svetlina Anati
Telerik team
 answered on 16 Jan 2009
Narrow your results
Selected tags
Tags
+? more
Top users last month
Shiori
Top achievements
Rank 2
Iron
Tien
Top achievements
Rank 1
Iron
Robert
Top achievements
Rank 1
Rob
Top achievements
Rank 4
Bronze
Bronze
Iron
Geoff
Top achievements
Rank 1
Want to show your ninja superpower to fellow developers?
Top users last month
Shiori
Top achievements
Rank 2
Iron
Tien
Top achievements
Rank 1
Iron
Robert
Top achievements
Rank 1
Rob
Top achievements
Rank 4
Bronze
Bronze
Iron
Geoff
Top achievements
Rank 1
Want to show your ninja superpower to fellow developers?
Want to show your ninja superpower to fellow developers?