This is a migrated thread and some comments may be shown as answers.

Where to set AllowedFileExtensions property for RadUpload in RadGrid

2 Answers 128 Views
Upload (Obsolete)
This is a migrated thread and some comments may be shown as answers.
Bernard
Top achievements
Rank 1
Bernard asked on 25 Jun 2011, 04:48 AM
Hi,

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.

Thanks,
Bernard

2 Answers, 1 is accepted

Sort by
0
Cori
Top achievements
Rank 2
answered on 29 Jun 2011, 01:17 PM
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.
0
Peter Filipov
Telerik team
answered on 29 Jun 2011, 02:49 PM
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.

Tags
Upload (Obsolete)
Asked by
Bernard
Top achievements
Rank 1
Answers by
Cori
Top achievements
Rank 2
Peter Filipov
Telerik team
Share this question
or