1-888-365-2779
+1-888-365-2779
Try Now
More in this section

Forums / Developing with Sitefinity / RadGrid Add Item displays Telerik.Web.UI.GridInsertionObject

RadGrid Add Item displays Telerik.Web.UI.GridInsertionObject

4 posts, 0 answered
  1. Mike
    Mike avatar
    208 posts
    Registered:
    10 Dec 2007
    31 Oct 2008
    Link to this post
    Hi All,

    I'm implementing a custom type editor based on the great info in this article:

    http://www.sitefinity.com/help/developer-manual/controls-adding-controls-type-editors.html

    My custom editor uses the RadGrid control as well, but when I click Add New Item, the text boxes for the new item have the following text in them:

    Telerik.Web.UI.GridInsertionObject

    Is there any way to override this behavior so that the text boxes start out empty when a new item is created?

    Thanks again in advance!
    Mike
  2. Pepi
    Pepi avatar
    981 posts
    Registered:
    31 Jan 2017
    03 Nov 2008
    Link to this post
    Hello Mike,

    Unfortunately, we cannot reproduce the described behavior locally.
    I would suggest you use the following code to set empty string for the text boxes in insert mode:

    protected override void CreateChildControls() 
        { 
            ... 
            dialogContainer.LinksGrid.ItemDataBound += new GridItemEventHandler(LinksGrid_ItemDataBound); 
            ... 
        } 
     
        void LinksGrid_ItemDataBound(object sender, GridItemEventArgs e) 
        { 
            if ((e.Item is GridEditFormInsertItem) && (e.Item.OwnerTableView.IsItemInserted)) 
            { 
                GridEditFormInsertItem edititem = (GridEditFormInsertItem)e.Item; 
                TextBox txtbx; 
                txtbx = (TextBox)edititem["Key"].Controls[0]; 
                if(txtbx != null
                    txtbx.Text = string.Empty; 
                if(txtbx != null
                    txtbx = (TextBox)edititem["Value"].Controls[0]; 
                txtbx.Text = string.Empty; 
            }  
        } 

    If the above does not help, please send us your implementation to test it locally. For your convenience we have transferred your forum post to our support ticketing system so you can attach files.

    Regards,
    Pepi
    the Telerik team

    Check out Telerik Trainer, the state of the art learning tool for Telerik products.
  3. Mike
    Mike avatar
    208 posts
    Registered:
    10 Dec 2007
    03 Nov 2008
    Link to this post
    Thanks Pepi, your code solved it.  I knew there would be some trick like that, but I couldn't find any documentation on how to access the edit fields.  I suppose this is documented somewhere in the RadGrid docs?

    Great support as usual! 

    I'm not sure how to close the support ticket you opened for this...I just looked on My Client.net and it's not there (not surprising, as  you probably have hundreds of "Mikes" who are customers.

    Thanks again,
    Mike
  4. Pepi
    Pepi avatar
    981 posts
    Registered:
    31 Jan 2017
    04 Nov 2008
    Link to this post
    Hi Mike,

    You could find more information on this matter in RadGrid for ASP.NET AJAX online documentation: Distinguish edit/insert mode on ItemCreated/ItemDataBound

    Best wishes,
    Pepi
    the Telerik team

    Check out Telerik Trainer, the state of the art learning tool for Telerik products.
Register for webinar
4 posts, 0 answered