Insert default values in gridtemplate editmode=popup

2 posts, 0 answers
  1. Harald
    Harald avatar
    5 posts
    Member since:
    Jun 2012

    Posted 21 Jun 2016 Link to this post

    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.


  2. Eyup
    Eyup avatar
    4085 posts

    Posted 23 Jun 2016 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:
    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
                // edit mode logic

    And access the generated controls to set their initial value for user convenience:

    I hope this will prove helpful.

    Do you need help with upgrading your ASP.NET AJAX, WPF or WinForms projects? Check the Telerik API Analyzer and share your thoughts.
Back to Top