Hello,
I build whole grid programmatically from Page_Init and assign DataSource to dynamically built datasource. I can edit data wihout any problems and now I try to insert row. That's what I do:
1. From client side I fire insert command:
Below is example of my control which I place in TemplateColumn
I build whole grid programmatically from Page_Init and assign DataSource to dynamically built datasource. I can edit data wihout any problems and now I try to insert row. That's what I do:
1. From client side I fire insert command:
var master = $find(gridID).get_masterTableView(); master.fireCommand("InitInsert", "");2. New empty row appears and I enter all data and press Save button. On server side I handle ItemCommand event like this:
case PerformInsertCommandName: GridEditableItem newItem = MasterTableView.GetInsertItem(); Dictionary<string, object> newValues = new Dictionary<string, object>(); newItem.ExtractValues(newValues); break;and newValues always contain empty values. I try to find controls directly like
WebControl ctl = newItem.FindControl<WebControl>(c => c is IZSheetControl);but control's value is always null anyway. Have I missed anything?
Below is example of my control which I place in TemplateColumn
public class ZTextBox : TextBox, IScriptControl, IZSheetControl { private ScriptManager sm; public ZTextBox(ZSheetItem item) { Item = item; } #region IZSheetControl public ZSheetItem Item { get; set; } public object Value { get { return Text; } set { Text = value == null ? string.Empty : value.ToString(); } } public int MinWidth { get { return 120; } } #endregion #region IScriptControl IEnumerable<ScriptReference> IScriptControl.GetScriptReferences() { ScriptReference reference = new ScriptReference { Assembly = "UpeWeb.ASPNET.UI", Name = "UpeWeb.ASPNET.UI.Scripts.ZTextBox.js", #if DEBUG ScriptMode = ScriptMode.Debug, #else ScriptMode = ScriptMode.Release, #endif }; yield return reference; } IEnumerable<ScriptDescriptor> IScriptControl.GetScriptDescriptors() { var control = new ScriptControlDescriptor("UpeWeb.ASPNET.UI.Controls.ZTextBox", ClientID); control.AddProperty("text", Text); yield return control; } #endregion protected override void OnPreRender(EventArgs e) { if (!DesignMode) { sm = ScriptManager.GetCurrent(Page); if (sm == null) throw new HttpException("A ScriptManager control must exist on the current page."); sm.RegisterScriptControl(this); } base.OnPreRender(e); } protected override void Render(HtmlTextWriter writer) { if (!DesignMode) sm.RegisterScriptDescriptors(this); base.Render(writer); } }