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 List06. if (!Page.IsPostBack) //this is required to prevent the slected value of the drop downs being reverted during the data save07. {08. 09. using (CADWEntities DDLGender = new CADWEntities())10. {11. var GenderDropDownQuery = from Link in DDLGender.GenderViewEFs12. 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 List20. using (CADWEntities DDLRace = new CADWEntities())21. {22. var RaceDropDownQuery = from Link in DDLRace.RaceViewEFs23. 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 DataItem33. {34. get35. {36. return this._dataItem;37. }38. set39. {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
