Hello,
I am using version 2011.2.816 of the ASP.NET AJAX grid control and seem to be experiencing some issues with EditInPlace and the GridHTMLEditor column. In particular, when adding or updating a row, the text value obtained from the GridHTMLEditorColumn control is always empty. I noticed that if I removed the grid from the AjaxManager Ajax settings or if I changed the edit command column button type to LinkButton (or PushButton), everything would work fine.
Provided is a sample of the markup and code behind that will reproduce the problem.
Any help in resolving this issue would be greatly appreciated.
Thanks,
Tony
I am using version 2011.2.816 of the ASP.NET AJAX grid control and seem to be experiencing some issues with EditInPlace and the GridHTMLEditor column. In particular, when adding or updating a row, the text value obtained from the GridHTMLEditorColumn control is always empty. I noticed that if I removed the grid from the AjaxManager Ajax settings or if I changed the edit command column button type to LinkButton (or PushButton), everything would work fine.
Provided is a sample of the markup and code behind that will reproduce the problem.
<html xmlns="http://www.w3.org/1999/xhtml"><head runat="server"> <title></title></head><body> <form id="form1" runat="server"> <telerik:RadScriptManager ID="RadScriptManager1" runat="server"></telerik:RadScriptManager> <telerik:RadAjaxManager ID="RadAjaxManager1" runat="server"></telerik:RadAjaxManager> <div> <asp:PlaceHolder ID="PlaceHolder1" runat="server"></asp:PlaceHolder> </div> </form></body></html>using System;using System.Collections.Generic;using System.Linq;using System.Web;using System.Web.UI;using System.Web.UI.WebControls;using Telerik.Web.UI;public partial class Default3 : System.Web.UI.Page{ protected RadGrid RadGridNote = null; private int NoteId { get { if (ViewState["Id"] == null) { ViewState["Id"] = 0; } ViewState["Id"] = (int)ViewState["Id"] + 1; return (int)ViewState["Id"]; } } private List<Note> NotesList { get { if (ViewState["NotesList"] == null) { // Initialize list. List<Note> list = new List<Note>(); Note note; note = new Note(); note.NoteId = NoteId; note.NoteText = "This is the first note."; list.Add(note); note = new Note(); note.NoteId = NoteId; note.NoteText = "This is the seconds note."; list.Add(note); ViewState["NotesList"] = list; } return (List<Note>)ViewState["NotesList"]; } set { ViewState["NotesList"] = value; } } override protected void OnInit(EventArgs e) { base.OnInit(e); InitializeGridNote(); } protected void Page_Load(object sender, EventArgs e) { RadAjaxManager1.AjaxSettings.AddAjaxSetting(RadGridNote, RadGridNote); } private void InitializeGridNote() { GridBoundColumn boundColumn; GridButtonColumn buttonColumn; GridEditCommandColumn editCommandColumn; GridHTMLEditorColumn htmlEditorColumn; this.RadGridNote = new RadGrid(); // Set required event handlers. RadGridNote.NeedDataSource += new GridNeedDataSourceEventHandler(RadGridNote_NeedDataSource); RadGridNote.InsertCommand += new GridCommandEventHandler(RadGridNote_InsertCommand); RadGridNote.UpdateCommand += new GridCommandEventHandler(RadGridNote_UpdateCommand); RadGridNote.DeleteCommand += new GridCommandEventHandler(RadGridNote_DeleteCommand); RadGridNote.ID = "RadGridNote"; RadGridNote.AutoGenerateColumns = false; RadGridNote.AllowMultiRowEdit = false; RadGridNote.AllowSorting = true; RadGridNote.Width = Unit.Percentage(100); RadGridNote.ClientSettings.Selecting.AllowRowSelect = true; RadGridNote.MasterTableView.DataKeyNames = new string[] { "NoteId" }; RadGridNote.MasterTableView.DataMember = "Note"; RadGridNote.MasterTableView.EditMode = GridEditMode.InPlace; RadGridNote.MasterTableView.CommandItemDisplay = GridCommandItemDisplay.Top; RadGridNote.MasterTableView.CommandItemSettings.AddNewRecordText = "Add New Note"; // Edit button. editCommandColumn = new GridEditCommandColumn(); RadGridNote.MasterTableView.Columns.Add(editCommandColumn); editCommandColumn.ButtonType = GridButtonColumnType.ImageButton; editCommandColumn.UniqueName = "EditCommandColumn"; editCommandColumn.ItemStyle.Width = Unit.Percentage(10); // Delete button. buttonColumn = new GridButtonColumn(); RadGridNote.MasterTableView.Columns.Add(buttonColumn); buttonColumn.ButtonType = GridButtonColumnType.ImageButton; buttonColumn.UniqueName = "DeleteCommandColumn"; buttonColumn.CommandName = "Delete"; buttonColumn.ItemStyle.Width = Unit.Percentage(5); boundColumn = new GridBoundColumn(); RadGridNote.MasterTableView.Columns.Add(boundColumn); boundColumn.ReadOnly = true; boundColumn.UniqueName = "NoteId"; boundColumn.DataField = "NoteId"; boundColumn.HeaderText = "Id"; boundColumn.ItemStyle.Width = Unit.Percentage(10); htmlEditorColumn = new GridHTMLEditorColumn(); RadGridNote.MasterTableView.Columns.Add(htmlEditorColumn); htmlEditorColumn.UniqueName = "NoteText"; htmlEditorColumn.DataField = "NoteText"; htmlEditorColumn.HeaderText = "Note"; htmlEditorColumn.ItemStyle.Width = Unit.Percentage(75); PlaceHolder1.Controls.Add(RadGridNote); } void RadGridNote_NeedDataSource(object sender, GridNeedDataSourceEventArgs e) { RadGridNote.MasterTableView.DataSource = NotesList; } void RadGridNote_InsertCommand(object sender, GridCommandEventArgs e) { GridEditableItem editedItem = e.Item as GridEditableItem; GridEditManager editManager = editedItem.EditManager; Note note = new Note(); note.NoteId = NoteId; note.NoteText = (editManager.GetColumnEditor("NoteText") as GridHTMLEditorColumnEditor).Editor.Content; NotesList.Add(note); } void RadGridNote_UpdateCommand(object sender, GridCommandEventArgs e) { GridEditableItem editedItem = e.Item as GridEditableItem; GridEditManager editManager = editedItem.EditManager; // Obtain the ID for the contract step. int noteId = int.Parse(editedItem.GetDataKeyValue("NoteId").ToString()); Note foundNote = NotesList.Find(delegate(Note note) { return (note.NoteId == noteId); }); if (foundNote != null) { foundNote.NoteText = (editManager.GetColumnEditor("NoteText") as GridHTMLEditorColumnEditor).Editor.Content; } } void RadGridNote_DeleteCommand(object sender, GridCommandEventArgs e) { GridEditableItem editedItem = e.Item as GridEditableItem; GridEditManager editManager = editedItem.EditManager; // Obtain the ID for the contract step. int noteId = int.Parse(editedItem.GetDataKeyValue("NoteId").ToString()); Note foundNote = NotesList.Find(delegate(Note note) { return (note.NoteId == noteId); }); if (foundNote != null) { NotesList.Remove(foundNote); } } [Serializable] private class Note { public int NoteId { get; set; } public string NoteText { get; set; } }}Any help in resolving this issue would be greatly appreciated.
Thanks,
Tony