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

[Solved] Get Values FileUpLoad in RadGrid

1 Answer 181 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Dao
Top achievements
Rank 1
Dao asked on 17 Jun 2009, 05:21 AM
Code:

Aspx:

<telerik:GridTemplateColumn UniqueName="Temp" HeaderText="Title" Visible="false">
                                    <ItemTemplate>
                                    ....
                                    </ItemTemplate>
                                    <EditItemTemplate>
                                        <asp:FileUpload ID="FileUpload1" runat="server" />
                                    </EditItemTemplate>
</telerik:GridTemplateColumn>

When Click Insert:

C#:
protected void RadGrid1_InsertCommand(object source, Telerik.Web.UI.GridCommandEventArgs e)
    {
        GridEditFormInsertItem InsertItem = (GridEditFormInsertItem)e.Item;
        FileUpload strvanban = (FileUpload)InsertItem ["Temp"].FindControl("FileUpload1");
        string strfilename = strvanban.FileName;
        string strpath = "/Uploadfiles/";
        strfilename.SaveAs(Server.MapPath(".") + strpath + strfilename );
..........
    }

Get values = "". Help me get Value strfilename

Thanks

1 Answer, 1 is accepted

Sort by
0
Princy
Top achievements
Rank 2
answered on 17 Jun 2009, 08:07 AM
Hello Dao,

I am not sure as to what exactly is your requirement. I found out a few changes that you should be adding to the code in your InsertCommand which is highligted in the code below. Also if you want to access the filename outside the insert command, then you can pass the filename to a globally accessible variable in the InsertCommand.
c#:
    string strfilename; 
    protected void RadGrid1_InsertCommand(object source, GridCommandEventArgs e)  
    {  
        GridEditFormInsertItem insertItem = (GridEditFormInsertItem)e.Item;  
        FileUpload strvanban = (FileUpload)insertItem["Temp"].FindControl("FileUpload1");  
        strfilename = strvanban.FileName;  
        string strpath = "\\Uploadfiles\\";  
        strvanban.SaveAs(Server.MapPath(".") + strpath + strfilename);  
        .....  
         
    }  
 
    protected void RadGrid1_PreRender(object sender, EventArgs e) 
    { 
        string fileName = strfilename;        
    } 
If this is not what you require, please explain a bit more on what you are trying to achieve.

Thanks
Princy.
Tags
Grid
Asked by
Dao
Top achievements
Rank 1
Answers by
Princy
Top achievements
Rank 2
Share this question
or