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

[Solved] File Upload Within RadGrid

1 Answer 494 Views
Grid
This is a migrated thread and some comments may be shown as answers.
James Greaves
Top achievements
Rank 2
James Greaves asked on 29 Jan 2010, 11:14 AM
I am having some issues with a file upload within a radGrid Edit Template.

I have a table of data which consists of a number of varchar columns and one field for images.  Images are not stored as binary, only a string reference to the file location.

I would like the user to be able to click the edit button and a template showing a file upload control.  Which will allow the user to upload an image, then when the image is uploaded to update the textual path in the database row.

I can currently upload the file but the itemupdated event never fires and I am having issues gathering the row details in the grid (Part  No, Part Revision).

     <telerik:RadProgressManager ID="RadProgressManager1" runat="server"  />  
        <telerik:RadProgressArea ID="RadProgressArea1" runat="server" />  
 
        <telerik:RadGrid ID="RadGridImageUpload" runat="server"   
            DataSourceID="SqlDataSourceImagePart" GridLines="None" AllowPaging="True" AllowAutomaticUpdates="false" AllowAutomaticDeletes="false" AllowAutomaticInserts="false" 
            AllowSorting="True" AutoGenerateEditColumn="True">  
<MasterTableView AutoGenerateColumns="False" DataSourceID="SqlDataSourceImagePart">  
<RowIndicatorColumn>  
<HeaderStyle Width="20px"></HeaderStyle>  
</RowIndicatorColumn>  
 
<ExpandCollapseColumn>  
<HeaderStyle Width="20px"></HeaderStyle>  
</ExpandCollapseColumn>  
    <Columns>  
 
        <telerik:GridBoundColumn DataField="PART_NO" HeaderText="PART_NO"   
            SortExpression="PART_NO" UniqueName="PART_NO">  
        </telerik:GridBoundColumn>  
        <telerik:GridBoundColumn DataField="REV_NO" HeaderText="REV_NO"   
            SortExpression="REV_NO" UniqueName="REV_NO">  
        </telerik:GridBoundColumn>  
              <telerik:GridBoundColumn DataField="STATE" HeaderText="STATE"   
            SortExpression="STATE" UniqueName="STATE">  
        </telerik:GridBoundColumn>  
       
 
        <telerik:GridImageColumn UniqueName="ImagecolumnPart" HeaderText="Image" DataImageUrlFields="IMAGEPATH"   
        DataImageUrlFormatString="~/ApplicationImages/Thumbs/{0}" DataAlternateTextField="PART_NO" ></telerik:GridImageColumn>  
    </Columns>  
    <EditFormSettings EditFormType="Template">  
      
    <FormTemplate>  
              
                  
          <telerik:RadUpload ID="RadUpload1" runat="server" MaxFileInputsCount="1"    
          OnValidatingFile="RadUpload1_FileExists" TargetFolder="~/ApplicationImages/"   
          OverwriteExistingFiles="false">  
        </telerik:RadUpload>  
   
          
        <br />  
        <asp:Button ID="ButtonSubmit" runat="server" Text="Submit" onclick="ButtonSubmit_Click"/>  
    </FormTemplate>  
    </EditFormSettings>  
</MasterTableView>  
        </telerik:RadGrid>  
      
      
        <asp:SqlDataSource ID="SqlDataSourceImagePart" runat="server"   
            ConnectionString="<%$ ConnectionStrings:DIG_ConnectionString %>"   
            SelectCommand="SELECT * FROM [DIG_ENG_PART_REVISION] ">  
        </asp:SqlDataSource> 


Above is the code for the grid.  I am currently handling the image (creating a thumb) in the upload 'OnValidatingFile' Event. 

Essentially this project calls for a list of parts to be displayed in a grid or list and for the user to be able to update/delete images for this part.
I have spent quite a while looking at this issue and I cannot help think I am overthinking it. 

As always your help is appreciated!


Cheers,



1 Answer, 1 is accepted

Sort by
0
Iana Tsolova
Telerik team
answered on 03 Feb 2010, 04:14 PM
Hi James,

I went through your code and I assume that you want to update the database when the "ButtonSubmit" button is clicked. However, if you want it to fire the grid UpdateCommand event, you need to set its CommandName property to "Update".

Check it out and let me know if this helps.

Greetings,
Iana
the Telerik team

Watch a video on how to optimize your support resource searches and check out more tips on the blogs.
Follow the status of features or bugs in PITS and vote for them to affect their priority.
Tags
Grid
Asked by
James Greaves
Top achievements
Rank 2
Answers by
Iana Tsolova
Telerik team
Share this question
or