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

Fileupload control in side Ajax RadGrid control Edit mode

6 Answers 156 Views
Grid
This is a migrated thread and some comments may be shown as answers.
PM
Top achievements
Rank 1
PM asked on 17 Dec 2009, 07:17 AM
Hi All,

I have a FileUpload control inside Ajax RadGrid Insert / Edit Mode. (I mean, when i Add / Edit a record from Ajax RadGrid i want to select a file and save it at some place and save the file name in to database table.)

My issue is, i am not able to get the file path or name which i selected in FileUpload control at Ajax RadGrid "RadGrid1_InsertCommand" and "RadGrid1_UpdateCommand" event.

Please help me regarding this how can i achieve this task.




6 Answers, 1 is accepted

Sort by
0
Shinu
Top achievements
Rank 2
answered on 17 Dec 2009, 12:34 PM
Hi Praveen,

You can try the following code snippet in order to access the RadUpload control placed in the EditItemTemplate.

ASPX:
 
<telerik:GridTemplateColumn> 
    <EditItemTemplate> 
        <telerik:RadUpload ID="RadUpload1" runat="server"
        </telerik:RadUpload> 
    </EditItemTemplate> 
</telerik:GridTemplateColumn> 

CS:
 
    protected void RadGrid1_InsertCommand(object source, GridCommandEventArgs e) 
    { 
        GridEditFormInsertItem insertItem = (GridEditFormInsertItem)e.Item; 
        RadUpload upload = (RadUpload)insertItem.FindControl("RadUpload1"); 
        Response.Write(upload.UploadedFiles[0].FileName); // get the path 
    } 
    protected void RadGrid1_UpdateCommand(object source, GridCommandEventArgs e) 
    { 
        GridEditFormItem editItem = (GridEditFormItem)e.Item; 
        RadUpload upload = (RadUpload)editItem.FindControl("RadUpload1"); 
        Response.Write(upload.UploadedFiles[0].FileName); // get the path 
    } 

-Shinu.
0
PM
Top achievements
Rank 1
answered on 18 Dec 2009, 08:10 AM
i did as you said, but i am getting following erroe

Index was out of range. Must be non-negative and less than the size of the collection.
Parameter name: index

Actually i am using "RadAjaxLoadingPanel1"

<telerik:RadAjaxManager ID="RadAjaxManager1" runat="server">
<AjaxSettings>
                    <telerik:AjaxSetting AjaxControlID="RadGrid1">
                        <UpdatedControls>
                            <telerik:AjaxUpdatedControl ControlID="RadGrid1" />                            
                        </UpdatedControls>
                    </telerik:AjaxSetting>                    
                </AjaxSettings>
</telerik:RadAjaxManager>
<telerik:RadAjaxLoadingPanel ID="RadAjaxLoadingPanel1" runat="server">
</telerik:RadAjaxLoadingPanel>
0
Nikolay Rusev
Telerik team
answered on 21 Dec 2009, 06:50 AM
Hello Praveen,

You can try new GridAttachmentColumn that has RadUpload for its editor. Please check the example bellow:
http://demos.telerik.com/aspnet-ajax/grid/examples/generalfeatures/gridattachmentcolumn/defaultcs.aspx

I hope this will help attain desired functionality.

Greetings,
Nikolay
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.
0
Nicolaï
Top achievements
Rank 2
answered on 05 Nov 2010, 11:44 AM
That sample page generates an error page when you try to add a file?
0
Sebastian
Telerik team
answered on 05 Nov 2010, 12:17 PM
Hi Nicolai,

I tested the sample under IE 7/8 and FF 3.x and the insert functionality worked without generating errors. Can you retest it on your machine and specify the browser and its version you use? This can help us track down the cause of the abnormality to address it accordingly.

Best regards,
Sebastian
the Telerik team
Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items
0
Nicolaï
Top achievements
Rank 2
answered on 08 Nov 2010, 03:41 PM
It works.
I was probably forgetting either a date or the added by field, which gives a page not found.. 
Tags
Grid
Asked by
PM
Top achievements
Rank 1
Answers by
Shinu
Top achievements
Rank 2
PM
Top achievements
Rank 1
Nikolay Rusev
Telerik team
Nicolaï
Top achievements
Rank 2
Sebastian
Telerik team
Share this question
or