Where to set AllowedFileExtensions property for RadUpload in RadGrid

Thread is closed for posting
3 posts, 0 answers
  1. Bernard
    Bernard avatar
    5 posts
    Member since:
    Jun 2011

    Posted 24 Jun 2011 Link to this post


    I have a RadUpload in a RadGrid. I would like set the AllowedFileExtensions property at the code-behind rather through the aspx page itself. In which event should I set this? I've tried it in the '... Insert' event, but it seems that the code does not detect it and allowed the invalid files to go through.

  2. Cori
    Cori avatar
    562 posts
    Member since:
    Jul 2010

    Posted 29 Jun 2011 Link to this post

    Hello Bernard,

    You would set it in the ItemCreated event. It would look something like this:

    if (e.Item is GridEditableItem && e.Item.IsInEditMode)
         GridEditableItem editItem = (GridEditableItem)e.item;
         GridTemplateColumnEditor uploadEditor = (GridTemplateColumnEditor)editItem.EditManager.GetColumnEditor("columnUniqueName");
          .....additional code to pull upload control.....

    What the code does above is check that the grid in edit mode (raised during insert/update) and that the item is a GridEditableItem (that is the item you'll need in order to access the controls). Now depending on the column type you're using, I'm assuming it's a GridTemplateColumn, but if it's another type you'll need to change the conversion to that column editor type.

    From there you'll do a FindControl to pull out your RadUpload control and then set the AllowedFileExtensions property.

    I hope that helps.
  3. DevCraft R3 2016 release webinar banner
  4. Peter Filipov
    Peter Filipov avatar
    1028 posts

    Posted 29 Jun 2011 Link to this post

    Hi Bernard,

    You may also use the ItemDataBound event. Please consult with the attached project.

    Kind regards,
    Peter Filipov
    the Telerik team

    Browse the vast support resources we have to jump start your development with RadControls for ASP.NET AJAX. See how to integrate our AJAX controls seamlessly in SharePoint 2007/2010 visiting our common SharePoint portal.

Back to Top