Insert default values in gridtemplate editmode=popup

2 posts, 0 answers
  1. Harald Gläser
    Harald Gläser avatar
    4 posts
    Member since:
    Jun 2012

    Posted 21 Jun Link to this post

    Hallo,
    when I am use radgrid editmode=popup with a web user controll with insert action the template was displayed with empty field (no datarecord was bound).
    For a better useibility I want to preset the template fields with default values. But how can I do this? To set the fields in the user control has no affect becaus it would be overitten after bounding to the empty insert record.

    Harald

  2. Eyup
    Admin
    Eyup avatar
    3014 posts

    Posted 23 Jun Link to this post

    Hi Harald,

    You can use the ItemDataBound event handler to achieve this requirement. Distinguish the edit form from the insert form:
    http://docs.telerik.com/devtools/aspnet-ajax/controls/grid/data-editing/distinguish-edit-or-insert-mode
    Copy Code
    Copy Code
    protected void RadGrid1_ItemDataBound(object sender, GridItemEventArgs e)
    {
        if (e.Item.IsInEditMode)
        {
            GridEditableItem item = e.Item as GridEditableItem;
            if (item is IGridInsertItem)
            {
                // insert mode logic
            }
            else
            {
                // edit mode logic
            }
        }
    }

    And access the generated controls to set their initial value for user convenience:
    http://docs.telerik.com/devtools/aspnet-ajax/controls/grid/rows/accessing-cells-and-rows#accessing-controls-in-editinsert-mode

    I hope this will prove helpful.

    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.
  3. UI for ASP.NET Ajax is Ready for VS 2017
Back to Top