DataBinding: ‘Telerik.Web.UI.GridInsertionObject’ does not contain a property with the name ‘UserName’.

I use the Telerik controls for a lot of my web work. They save a lot of time but every once in a while they really irritate the hell out of me. A few hours down the rabbit hole and I find that when binding to an EntityDataSource on a RadGrid when trying to insert an item on an empty list. i.e. no records yet, you get the title error.

So, what is the work around? A dummy row on an empty insert. Awesome huh. Well, at least it works.

  protected void dgAuthorizedUsers_ItemCommand(object source, Telerik.Web.UI.GridCommandEventArgs e)
        if (e.CommandName == Telerik.Web.UI.RadGrid.InitInsertCommandName )
            e.Canceled = true;
            var newVals = new System.Collections.Specialized.ListDictionary();
            newVals["UserName"] = string.Empty;

Make sure to add all the different fields you use. So much for declarative programming eh?

0 thoughts on “DataBinding: ‘Telerik.Web.UI.GridInsertionObject’ does not contain a property with the name ‘UserName’.”

  1. There is also an easy way if using a web user control.
    if (DataItem.GetType().ToString() == “Telerik.Web.UI.GridInsertionObject”)
    //set your form values

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.