Need Help with RadGrid EditItemTemplate

5 posts, 1 answers
  1. Perry
    Perry avatar
    62 posts
    Member since:
    Jul 2015

    Posted 17 Nov 2015 Link to this post

    I am attempting to create a custom Edit Item Template using this Telerik demo as a guide:

    So far I have created my web form ASCX page and the code behind for that page. I getting the new custom form to display when I click the edit button.  However when the form opens I do not see the data from the record I want to edit, all I see is an empty form, plus the update and cancel buttons are not showing. I have attached a screen shot titled EmptyForm.png. showing what I have so far.


    Below is the C# code for the ASCX web form:


    01.private object _dataItem = null;
    03.        protected void Page_Load(object sender, EventArgs e)
    04.        {
    05.           //Popuate the Gender Dropdown List
    06.            if (!Page.IsPostBack) //this is required to prevent the slected value of the drop downs being reverted during the data save
    07.            {
    09.                using (CADWEntities DDLGender = new CADWEntities())
    10.                {
    11.                    var GenderDropDownQuery = from Link in DDLGender.GenderViewEFs
    12.                                              select new { Link.GenderDescription, Link.GenderCode };
    13.                    DropDownListGender.DataValueField = "GenderCode";
    14.                    DropDownListGender.DataTextField = "GenderDescription";
    15.                    DropDownListGender.DataSource = GenderDropDownQuery.ToList();
    16.                    DropDownListGender.DataBind();
    17.                }
    19.                //Popuate the Race Dropdown List
    20.                using (CADWEntities DDLRace = new CADWEntities())
    21.                {
    22.                    var RaceDropDownQuery = from Link in DDLRace.RaceViewEFs
    23.                                            select new { Link.RaceDescription, Link.RaceCode };
    24.                    DropDownListRace.DataValueField = "RaceCode";
    25.                    DropDownListRace.DataTextField = "RaceDescription";
    26.                    DropDownListRace.DataSource = RaceDropDownQuery.ToList();
    27.                    DropDownListRace.DataBind();
    28.                }
    29.            }
    30.        }
    32.        public object DataItem
    33.        {
    34.            get
    35.            {
    36.                return this._dataItem;
    37.            }
    38.            set
    39.            {
    40.                this._dataItem = value;
    41.            }
    43.        }


    I am stuck on how to show the data for the selected record.  In the demo the code for the ASCX page just shows  // Put user code to initialize the page here.  Can someone help with an explanation of the code I need to show the selected record to edit,  and how I can get the cancel and Update buttons to show when the edit form opens.  Or perhaps another example that shows the code needed to display the selected record.





  2. Answer
    Eyup avatar
    4085 posts

    Posted 20 Nov 2015 Link to this post

    Hello Perry,

    I am sending a runnable isolated version of the mentioned sample. Please run the attached web site sample and let me know if it helps you.

    Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Feedback Portal and vote to affect the priority of the items
  3. Perry
    Perry avatar
    62 posts
    Member since:
    Jul 2015

    Posted 01 Dec 2015 in reply to Eyup Link to this post

    Sorry for the delay, I got pulled off onto another project.  Thank you very much for this information it was very helpful and I have resolved my problem.
  4. sharon
    sharon avatar
    27 posts
    Member since:
    Jul 2015

    Posted 11 May 2016 in reply to Eyup Link to this post

    Hi! Eyup,

      I have a question, in the sample provided, where is the EmployeeDetails_DataBinding coming from?

    this.DataBinding += new System.EventHandler(this.EmployeeDetails_DataBinding);

    Thanks, Sh

  5. Eyup
    Eyup avatar
    4085 posts

    Posted 16 May 2016 Link to this post

    Hi Sharon,

    It is the name of the corresponding event handler:
    protected void EmployeeDetails_DataBinding(object sender, System.EventArgs e)
        ArrayList tocs = new ArrayList(new string[] { "Dr.", "Mr.", "Mrs.", "Ms." });
        ddlTOC.DataSource = tocs;
        object tocValue = DataBinder.Eval(DataItem, "TitleOfCourtesy");
        if (tocValue == DBNull.Value)
            tocValue = "Mrs.";
        ddlTOC.SelectedIndex = tocs.IndexOf((string)tocValue);
        ddlTOC.DataSource = null;

    Do you need help with upgrading your ASP.NET AJAX, WPF or WinForms projects? Check the Telerik API Analyzer and share your thoughts.
Back to Top