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

Hierarchical radgrid with FileUpload control

3 Answers 116 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Mark Mobadder
Top achievements
Rank 2
Mark Mobadder asked on 30 Aug 2010, 03:22 PM

I have a hierarchical radgrid with 2 detail tables in it. I want to use fileupload control in one of the detail table. For this I placed a fileUpload control in one detail table as follows

 

<telerik:GridTemplateColumn DataField="sURL" HeaderButtonType="TextButton"

HeaderText="sURL" SortExpression="sURL" UniqueName="sURL">

<EditItemTemplate>

  <asp:FileUpload ID="sURLTextBox" runat="server"/>

</EditItemTemplate>

<ItemTemplate>

  <asp:Label ID="sURLLabel" runat="server" Text='<%# Eval("sURL") %>'></asp:Label>

</ItemTemplate>

</telerik:GridTemplateColumn>

 

 

Now on clicking the Update command in edit view of the grid, I want to save the filename selected using the fileupload browser.

Appreciate all your help.

Thanks

3 Answers, 1 is accepted

Sort by
0
Princy
Top achievements
Rank 2
answered on 31 Aug 2010, 08:40 AM
Hello Mark,

The following code snippet will help you to get the filename selected using FileUpload.

ASPX:
<DetailTables>
    <telerik:GridTableView Name="GridTableView1". . . .>
        <Columns>
            <telerik:GridTemplateColumn HeaderButtonType="TextButton" HeaderText="sURL" UniqueName="sURL">
                <EditItemTemplate>
                    <asp:FileUpload ID="sURLTextBox" runat="server" />
                </EditItemTemplate>
                <ItemTemplate>
                    <asp:Label ID="sURLLabel" runat="server"></asp:Label>
                </ItemTemplate>
            </telerik:GridTemplateColumn>
        </Columns>
    </telerik:GridTableView>
</DetailTables>

C#:
protected void RadGrid1_ItemCommand(object source, GridCommandEventArgs e)
   {
      if (e.CommandName == RadGrid.UpdateCommandName && e.Item.OwnerTableView.Name == "GridTableView1") // check whether it is the Update Command in DetailTable
       {
           GridEditFormItem editItem = (GridEditFormItem)e.Item;
           FileUpload fileUpload = (FileUpload)editItem.FindControl("sURLTextBox");
           string fileName = fileUpload.FileName; //get the file name
              //Update operation
       }
   }

Thanks,
Princy.
0
Ken Miller
Top achievements
Rank 1
answered on 09 Nov 2010, 12:48 AM
How would you perform the Update Operation?
0
Princy
Top achievements
Rank 2
answered on 09 Nov 2010, 05:35 AM
Hello Ken,

Please take a look at the following Code Library which explains how to perform manual insert/update/delete operations with sql statement from code behind.
Manual Insert/Update/Delete operations using Auto-generated editform with sql statements from the code-behind:

And the following Code Library  explains how to perform automatic operation in hierarchical grid using SqlDataSource.
Automatic operations in hierarchical grid with SqlDataSource control

Hope this helps,
Princy.
Tags
Grid
Asked by
Mark Mobadder
Top achievements
Rank 2
Answers by
Princy
Top achievements
Rank 2
Ken Miller
Top achievements
Rank 1
Share this question
or