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

[Solved] RadUpload in edititemtemplate

1 Answer 167 Views
Grid
This is a migrated thread and some comments may be shown as answers.
John Grymonprez
Top achievements
Rank 1
John Grymonprez asked on 26 Mar 2009, 11:21 AM
I am using a grid with automatic operations on a linqdatasource. One of the fields that needs to be updateable is a link to a file. There is a RadUpload control in the edititemtemplate, but I should be able to access this control to edit the link and then paste it in the textbox that is in the edititemtemplate.

Here is the code for the grid.

<telerik:RadGrid ID="rgReport" runat="server" AllowAutomaticDeletes="true"
                 AllowAutomaticInserts="true" AllowAutomaticUpdates="true" DataSourceID="LinqDataSource2"
                 AutoGenerateColumns="false" OnItemDataBound="rgReport_ItemDataBound"
                  OnUpdateCommand="rgReport_UpdateCommand">
                    <HeaderContextMenu EnableTheming="True">
                        <CollapseAnimation Duration="200" Type="OutQuint" />
                    </HeaderContextMenu>
                    <MasterTableView CommandItemDisplay="Top" DataKeyNames="SortID,BatchID,User_Ref"
                     EditMode="EditForms">
                         <Columns>
                            <telerik:GridEditCommandColumn ButtonType="ImageButton"
                                 UniqueName="EditCommandColumn">
                            </telerik:GridEditCommandColumn>
                            <telerik:GridBoundColumn DataField="SortID" HeaderText="SortID"
                             UniqueName="SortID" ReadOnly="true">
                                <ItemStyle CssClass="hide" />
                                <HeaderStyle CssClass="hide" />
                             </telerik:GridBoundColumn>
                             <telerik:GridBoundColumn DataField="newSort" HeaderText="Enclosure #"
                             UniqueName="EnclosureID">
                             </telerik:GridBoundColumn>
                             <telerik:GridBoundColumn DataField="Description" HeaderText="Description"
                              UniqueName="Description"></telerik:GridBoundColumn>
                             <telerik:GridBoundColumn DataField="Product_Ref" HeaderText="Product"
                              UniqueName="Product_Ref" ReadOnly="true">
                                <ItemStyle CssClass="hide" />
                                <HeaderStyle CssClass="hide" />
                             </telerik:GridBoundColumn>
                             <telerik:GridTemplateColumn UniqueName="tmplLink">
                                 <ItemTemplate>
                                     <asp:Label ID="lblLink" runat="server" Text='<%#Eval("Link") %>'></asp:Label>
                                 </ItemTemplate>
                                 <EditItemTemplate>
                                     <asp:TextBox ID="txtLink" Text='<%#Bind("Link") %>' runat="server"></asp:TextBox>
                                     <telerik:RadUpload ID="ruLink" OnClientFileSelected="fileSelected" runat="server" ControlObjectsVisibility="None" />
                                 </EditItemTemplate>
                             </telerik:GridTemplateColumn>
                             <telerik:GridBoundColumn DataField="Type" HeaderText="Type" UniqueName="Type"
                              ReadOnly="true">
                             </telerik:GridBoundColumn>
                            <telerik:GridButtonColumn ConfirmText="Delete this product?"
                                ConfirmDialogType="RadWindow" ConfirmTitle="Delete" ButtonType="ImageButton"  
                                CommandName="Delete" Text="Delete" UniqueName="DeleteColumn">
                                <ItemStyle HorizontalAlign="Center"/>
                            </telerik:GridButtonColumn>
                    </Columns>
                <editformsettings>
                    <editcolumn uniquename="EditCommandColumn1">
                    </editcolumn>
                </editformsettings>
                        <RowIndicatorColumn>
                            <HeaderStyle Width="20px" />
                        </RowIndicatorColumn>
                        <ExpandCollapseColumn>
                            <HeaderStyle Width="20px" />
                        </ExpandCollapseColumn>
                    </MasterTableView>
                    <FilterMenu EnableTheming="True">
                        <CollapseAnimation Duration="200" Type="OutQuint" />
                    </FilterMenu>
                </telerik:RadGrid>

1 Answer, 1 is accepted

Sort by
0
Accepted
Tsvetoslav
Telerik team
answered on 31 Mar 2009, 07:30 AM
Hi John Grymonprez,

You can access the upload control in the grid's UpdateCommand event as follows:

        if (e.Item is GridEditableItem && e.Item.IsInEditMode)  
        {  
 
            GridEditableItem item = e.Item as GridEditableItem;  
 
            RadUpload upload = item.FindControl("fileUpload"as RadUpload;  
 
            string fileName = upload.UploadedFiles[0].FileName;  
 
        } 

I hope this helps.

Best Regards,
Tsvetoslav
the Telerik team

Check out Telerik Trainer , the state of the art learning tool for Telerik products.
Tags
Grid
Asked by
John Grymonprez
Top achievements
Rank 1
Answers by
Tsvetoslav
Telerik team
Share this question
or