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

[Solved] RAD GRID EDITTEMPLATE FILEUPLOAD CONTROL

1 Answer 124 Views
Grid
This is a migrated thread and some comments may be shown as answers.
ratheesh
Top achievements
Rank 1
ratheesh asked on 09 Dec 2009, 12:07 PM
Hi ,

I have a file upload control in my rad grid editformtemplate and the posted file has to be saved on the click of a button
inside the template . The code for this has been placed inside the ItemCommand . The ItemCommand fires when i upload files with filenames having no special character or spaces between them , but when i try for files having special character or spaces between them
the event is not fired and the IE displays page cannot be found . Any Idea on  why this happens. 

.ASPX CODE:
<EditFormSettings EditFormType="Template">
                                                            <EditColumn UniqueName="EditCommandColumn">
                                                            </EditColumn>
                                                            <FormTemplate>
                                                                <table id="tableSupportingFilesTemplate" cellspacing="2" cellpadding="1" width="100%"
                                                                    border="0" rules="none" style="border-collapse: collapse; background: white;">
                                                                    <tr>
                                                                        <td width="2%">
                                                                        </td>
                                                                        <td colspan="3">
                                                                            <asp:CheckBox ID="checkBoxVisibleFiles" Enabled="false" runat="server" Checked='<%# (DataBinder.Eval(Container.DataItem,"VisibleToCustomer") is DBNull ?false:Eval("VisibleToCustomer")) %>'
                                                                                Text="Visible to the Customer/Prospect?" />
                                                                        </td>
                                                                    </tr>
                                                                    <tr>
                                                                        <td width="2%">
                                                                        </td>
                                                                        <td colspan="3">
                                                                            <asp:Label ID="labelFileText" runat="server" Text="File Name : "> </asp:Label>
                                                                            <asp:Label ID="labelFileName" Text='<%# Bind("OriginalFileName") %>' runat="server"></asp:Label>
                                                                        </td>
                                                                    </tr>
                                                                    <tr>
                                                                        <td width="2%">
                                                                        </td>
                                                                        <td colspan="3">
                                                                            <asp:FileUpload ID="fileUploadControl" runat="server" Width="50%" />
                                                                        </td>
                                                                    </tr>
</table>
 <FormTemplate>
                                                                

.CS CODE
ITEMCOMMAND EVENT
if (e.CommandName == "Insert")
        {
            if (e.Item is GridEditFormInsertItem)
            { 

FileUpload fileUploadCtrl = (FileUpload)insertFormItem.FindControl("fileUploadControl");
 if (fileUploadCtrl.HasFile == true)
                {
                    try
                    {

                        string fileName = Path.GetFileName(fileUploadCtrl.FileName);
                        fileUploadCtrl.SaveAs(System.Configuration.ConfigurationSettings.AppSettings["FilePath"].ToString() + "/" + GenerateRandomFileName(fileUploadCtrl));
 }
 
catch (Exception ex)
                    {

                    }

regards
Ratheesh

1 Answer, 1 is accepted

Sort by
0
Veli
Telerik team
answered on 14 Dec 2009, 12:43 PM
Hi ratheesh,

Can you give us some instructions on how to reproduce this error? What type of files are you trying to upload? Can you also  give us a sample file name that breaks the upload?


All the best,
Veli
the Telerik team

Instantly find answers to your questions on the new Telerik Support Portal.
Watch a video on how to optimize your support resource searches and check out more tips on the blogs.
Tags
Grid
Asked by
ratheesh
Top achievements
Rank 1
Answers by
Veli
Telerik team
Share this question
or