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

RadUpload inside EditItemTemplate on RadGrid problem

3 Answers 347 Views
Upload (Obsolete)
This is a migrated thread and some comments may be shown as answers.
Daniel Bichuete
Top achievements
Rank 1
Daniel Bichuete asked on 19 Sep 2009, 04:30 PM
Hi, I have a grid with the following code that is suposed to allow insert/update/delete of a module of our system. On ItemTemplate I show a link do download the file and on EditItemTemplate I tried to use a RadUpload to send the update. But I dont know how to ind the value of the RadUpload first file to the DataField Module.

How can I accomplish this ? I'm new to Telerik.


<telerik:RadGrid runat="server" ID="RadGrid1" AllowPaging="True" AllowSorting="True"
            AutoGenerateColumns="False" Width="97%" DataSourceID="SqlDataSource1" AllowAutomaticInserts="True"
            AllowAutomaticUpdates="True" AllowAutomaticDeletes="True" ShowStatusBar="True"
            GridLines="None" OnItemDataBound="RadGrid1_ItemDataBound" 
                 OnItemCreated="RadGrid1_ItemCreated" PageSize="3">
            <PagerStyle Mode="NumericPages" AlwaysVisible="true" />
            <MasterTableView Width="100%" CommandItemDisplay="Top" DataKeyNames="ID" DataSourceID="SqlDataSource1">
                <Columns>
                    <telerik:GridEditCommandColumn ButtonType="ImageButton">
                        <HeaderStyle Width="3%" />
                    </telerik:GridEditCommandColumn>
                    
                    <telerik:GridTemplateColumn DataField="Name" HeaderText="Name" 
                        SortExpression="Name" UniqueName="Name">
                        <ItemTemplate>
                            <asp:Label runat="server" ID="lblName" Text='<%# Eval("Name") %>' />
                        </ItemTemplate>
                        <EditItemTemplate>
                            <telerik:RadTextBox runat="server" Width="200px" ID="txbName" Text='<%# Bind("Name") %>' />
<asp:RequiredFieldValidator ID="Requiredfieldvalidator1" runat="server" ControlToValidate="txbName"
ErrorMessage="Please, enter a name!" Display="Dynamic" SetFocusOnError="true" />
                        </EditItemTemplate>
                        <HeaderStyle Width="30%" />
                    </telerik:GridTemplateColumn>
                    
                    <telerik:GridTemplateColumn DataField="Version" HeaderText="Version" 
                        SortExpression="Version" UniqueName="Version">
                         <ItemTemplate>
                            <asp:Label ID="lblDescription" runat="server" Text='<%# Eval("Version") %>' />
                            
                        </ItemTemplate>
                        <EditItemTemplate>
                            <telerik:RadTextBox ID="txbDescription" Width="300px" runat="server" TextMode="MultiLine"
                                Text='<%# Bind("Version") %>' Height="150px" />
                                <asp:RequiredFieldValidator ID="Requiredfieldvalidator2" runat="server" ControlToValidate="txbDescription"
ErrorMessage="Please, enter a name!" Display="Dynamic" SetFocusOnError="true" />
                        </EditItemTemplate>
                        <ItemStyle VerticalAlign="Top" />
                    </telerik:GridTemplateColumn>
                    
                    <telerik:GridTemplateColumn HeaderText="Módulo" UniqueName="Module" DataField="Module">
                        <ItemTemplate>
                            <asp:HyperLink ID="hlDownload" runat="server" NavigateUrl='<%# "teste.aspx?s=" + Eval("ID") %>'>Baixar</asp:HyperLink>
                        </ItemTemplate>
                        <EditItemTemplate>
                            <telerik:RadUpload ControlObjectsVisibility="None" MaxFileInputsCount="1" ID="RadUpload1" runat="server">
                            </telerik:RadUpload>
                        </EditItemTemplate>
                        <ItemStyle VerticalAlign="Top" />
                    </telerik:GridTemplateColumn>
                    
                    <telerik:GridButtonColumn Text="Delete" CommandName="Delete" ButtonType="ImageButton">
                        <HeaderStyle Width="2%" />
                    </telerik:GridButtonColumn>
                    
                </Columns>
                <EditFormSettings>
                    <EditColumn ButtonType="ImageButton" />
                </EditFormSettings>
            </MasterTableView> 
        </telerik:RadGrid>

3 Answers, 1 is accepted

Sort by
0
Princy
Top achievements
Rank 2
answered on 21 Sep 2009, 11:41 AM
Hello Daniel Bichuete,

You can try out the following code to access the selected file name from the RadUpload:
c#:
 protected void RadGrid1_ItemUpdated(object source, GridUpdatedEventArgs e) 
    { 
        GridEditableItem item = (GridEditableItem)e.Item; 
        RadUpload upload = (RadUpload)item.FindControl("RadUpload1"); 
        string file = upload.UploadedFiles[0].FileName; 
    } 

-Princy.
0
Daniel Bichuete
Top achievements
Rank 1
answered on 21 Sep 2009, 02:53 PM
Hi,

I tried your code and it isn't uploading the file to database. I would like to do similar to when using GridBinaryImageColumn. I would like to when in Edit mode the radupload control that I manually added upload to binary field in database.

Daniel Bichuete
0
Genady Sergeev
Telerik team
answered on 23 Sep 2009, 09:51 AM
Hi Daniel Bichuete,

For a sample on how to upload files to a database please take a look at this demo and at this code library. I hope they will help you to get started.

Kind regards,
Genady Sergeev
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
Upload (Obsolete)
Asked by
Daniel Bichuete
Top achievements
Rank 1
Answers by
Princy
Top achievements
Rank 2
Daniel Bichuete
Top achievements
Rank 1
Genady Sergeev
Telerik team
Share this question
or