GridAttachmentColumn Validation

2 posts, 0 answers
  1. Jack
    Jack avatar
    127 posts
    Member since:
    May 2003

    Posted 10 Sep 2012 Link to this post


    I'm following the GridAttachmentColumn demo and saving to the database - all works well, but in the demo, if no file is uploaded the error message is added like so:-

      RadGrid1.Controls.Add(New LiteralControl("<b style='color:red;'>No file uploaded. Action canceled.</b>"))

    This puts the message right at the bottom of the grid - is there a way to show it within the auto generated edit form please?

    Also, I did look but is there an example of the GridAttachmentColumn using an edit form template?



  2. Martin
    Martin avatar
    810 posts

    Posted 13 Sep 2012 Link to this post

    Hello Jon,

    Maybe you have noticed that this notification is just a LiteralControl added to the Grid's controls collection on the ItemCommand event. You can use the exact same approach, but add the LiteralControl to a control of your choice. Using the demo example here is how to move it just bellow the Update/Cancel buttons:

    protected void RadGrid1_ItemCommand(object source, GridCommandEventArgs e)
        if (e.CommandName == RadGrid.UpdateCommandName ||
            e.CommandName == RadGrid.PerformInsertCommandName)
            GridEditableItem item = e.Item as GridEditableItem;
            if (fileData.Length == 0 || fileName.Trim() == string.Empty)
                e.Canceled = true;
                item.FindControl("CancelButton").Parent.Controls.Add(new LiteralControl("<br/><b style='color:red;'>No file uploaded. Action canceled.</b>"));
                //RadGrid1.Controls.Add(new LiteralControl("<b style='color:red;'>No file uploaded. Action canceled.</b>"));

    Another approach you can follow is to add validator controls to your edit form. More information on the matter is available in the help article bellow:


    As to your second question - the FormTemplate edit form type supposes that developers want to have a complete control over the Edit Form content. Based on that the GridAttachmentColumn would not render any content in the edit form. Instead the form would contain what the developer have provided in the FormTemplate property of the TableView.

    I hope this helps.

    All the best,
    the Telerik team
    If you want to get updates on new releases, tips and tricks and sneak peeks at our product labs directly from the developers working on the RadControls for ASP.NET AJAX, subscribe to their blog feed now.
  3. DevCraft R3 2016 release webinar banner
Back to Top