RadUpload inside EditItemTemplate on RadGrid problem

Thread is closed for posting
4 posts, 0 answers
  1. Daniel Bichuete
    Daniel Bichuete avatar
    9 posts
    Member since:
    Sep 2009

    Posted 19 Sep 2009 Link to this post

    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>
  2. Princy
    Princy avatar
    17421 posts
    Member since:
    Mar 2007

    Posted 21 Sep 2009 Link to this post

    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.
  3. UI for ASP.NET Ajax is Ready for VS 2017
  4. Daniel Bichuete
    Daniel Bichuete avatar
    9 posts
    Member since:
    Sep 2009

    Posted 21 Sep 2009 Link to this post

    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
  5. Genady Sergeev
    Admin
    Genady Sergeev avatar
    1596 posts

    Posted 23 Sep 2009 Link to this post

    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.
Back to Top