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

Need Help with RadGrid EditItemTemplate

4 Answers 74 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Perry
Top achievements
Rank 1
Perry asked on 17 Nov 2015, 08:24 PM

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;
02. 
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.            {
08. 
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.                }
18. 
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.        }
31. 
32.        public object DataItem
33.        {
34.            get
35.            {
36.                return this._dataItem;
37.            }
38.            set
39.            {
40.                this._dataItem = value;
41.            }
42. 
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.

 

Thanks

Perry

 

4 Answers, 1 is accepted

Sort by
0
Accepted
Eyup
Telerik team
answered on 20 Nov 2015, 09:42 AM
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.

Regards,
Eyup
Telerik
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
0
Perry
Top achievements
Rank 1
answered on 01 Dec 2015, 12:57 PM
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.
0
sharon
Top achievements
Rank 1
answered on 12 May 2016, 02:33 AM

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

0
Eyup
Telerik team
answered on 16 May 2016, 11:06 AM
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;
    ddlTOC.DataBind();
 
    object tocValue = DataBinder.Eval(DataItem, "TitleOfCourtesy");
 
    if (tocValue == DBNull.Value)
    {
        tocValue = "Mrs.";
    }
    ddlTOC.SelectedIndex = tocs.IndexOf((string)tocValue);
    ddlTOC.DataSource = null;
}

Regards,
Eyup
Telerik
Do you need help with upgrading your ASP.NET AJAX, WPF or WinForms projects? Check the Telerik API Analyzer and share your thoughts.
Tags
Grid
Asked by
Perry
Top achievements
Rank 1
Answers by
Eyup
Telerik team
Perry
Top achievements
Rank 1
sharon
Top achievements
Rank 1
Share this question
or