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

GridAttachmentColumn losing uploaded file

1 Answer 42 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Cristian
Top achievements
Rank 1
Cristian asked on 13 Sep 2013, 04:36 PM
Hi guys.

I'm facing some problem with a GridAttachmentColumn in a Radgrid, the grid is created as follows:
<telerik:RadGrid ID="RadGrid5" runat="server" Width="737px" 
               AutoGenerateColumns="False" CellSpacing="0" GridLines="None"
               oninsertcommand="RadGrid5_InsertCommand" AllowPaging="True"
               Culture="es-MX" onneeddatasource="RadGrid5_NeedDataSource"
               onitemdatabound="RadGrid5_ItemDataBound1"
               onitemcreated="RadGrid5_ItemCreated">
                
<MasterTableView NoMasterRecordsText="No hay registros para mostrar" CommandItemDisplay="Top" EditMode="EditForms" DataKeyNames="fiIdDocumento">
<CommandItemSettings ExportToPdfText="Export to PDF"></CommandItemSettings>
 
<RowIndicatorColumn Visible="True" FilterControlAltText="Filter RowIndicator column">
<HeaderStyle Width="20px"></HeaderStyle>
</RowIndicatorColumn>
 
<ExpandCollapseColumn Visible="True" FilterControlAltText="Filter ExpandColumn column">
<HeaderStyle Width="20px"></HeaderStyle>
</ExpandCollapseColumn>
 
    <Columns>
         
        <telerik:GridBoundColumn FilterControlAltText="Filter column1 column"
            HeaderText="Consecutivo documento" ReadOnly="true" UniqueName="column1" DataField="fiIdDocumento">
        </telerik:GridBoundColumn>
        
        <telerik:GridDropDownColumn FilterControlAltText="Filter column2 column" HeaderText="Tipo de Documento" DataField="fiIdTipoDocto"
            UniqueName="columnTpo">
        </telerik:GridDropDownColumn>
         <telerik:GridNumericColumn FilterControlAltText="Filter column2 column" HeaderText="Número de Escritura" DataField="fiNumEscritura"
            UniqueName="columnNumEscritura" DataType="System.Int32" >
        </telerik:GridNumericColumn>
     
        <telerik:GridDateTimeColumn FilterControlAltText="Filter column4 column"  HeaderText="Fecha de Escritura" DataField="fdFechaEscritura"
            UniqueName="column4" DataFormatString="{0:d}">
        </telerik:GridDateTimeColumn>
 
               <telerik:GridNumericColumn FilterControlAltText="Filter column2 column" HeaderText="Número de Escritura" DataField="fiNumActa"
            UniqueName="columnNumAct" DataType="System.Int32" >
        </telerik:GridNumericColumn>
 
               <telerik:GridNumericColumn FilterControlAltText="Filter column2 column" HeaderText="Número de Notaría" DataField="fiNumNotaria"
            UniqueName="columnNumNot" Visible="True">
        </telerik:GridNumericColumn>
 
               <telerik:GridBoundColumn FilterControlAltText="Filter column2 column" HeaderText="Notario" DataField="fcNomNotario"
            UniqueName="columnNomNot">
        </telerik:GridBoundColumn>
         
         
 
 
               <telerik:GridDropDownColumn FilterControlAltText="Filter column2 column" HeaderText="Estado" DataField="fiIdCdNotaria"
            UniqueName="columnCdNot" Display="True">
        </telerik:GridDropDownColumn>
 
               <telerik:GridNumericColumn FilterControlAltText="Filter column2 column" HeaderText="Número Registro Público" DataField="fiNumAltaRegPub"
            UniqueName="columnNumRP" DataType="System.Int32" >
        </telerik:GridNumericColumn>
 
             <telerik:GridDateTimeColumn FilterControlAltText="Filter column4 column"  HeaderText="Fecha de Alta Registro Público" DataField="fdFechaAltaRegPub"
            UniqueName="columnFchRegPub" DataFormatString="{0:d}">
        </telerik:GridDateTimeColumn>
      <telerik:GridAttachmentColumn FileName="attachment"
                                FilterControlAltText="Filter column5 column" UniqueName="dfdsf"
                                  AttachmentDataField="fcUrlModActConst"
                        AttachmentKeyFields="fcUrlModActConst"
                        FileNameTextField="fcUrlModActConst"
                        DataTextField="fcUrlModActConst"
                                HeaderText="DOC. DIGITALIZADO" ButtonType="ImageButton"
                                ImageUrl="~/img/1338992378_folder.png">
                                <HeaderStyle Width="110px" />
                                <ItemStyle HorizontalAlign="Center" Width="110px" />
                            </telerik:GridAttachmentColumn>
    </Columns>
     <CommandItemSettings AddNewRecordText="Agregar elemento al catálogo" RefreshText="" />
      <EditFormSettings ColumnNumber="3" CaptionFormatString="Modificar la información de la Función: {0}"
                                          CaptionDataField="fiIdDocumento">
                            <FormTableItemStyle Wrap="False"></FormTableItemStyle>
                            <FormMainTableStyle GridLines="None" CellSpacing="0" CellPadding="2" Height="60px"
                                                Width="100%" />
                            <FormTableStyle GridLines="Horizontal" CellSpacing="0" CellPadding="2" Height="50px"
                                            Width="100%" />
                                             
                      
                            <FormStyle Width="100%" BackColor="#ebebeb"></FormStyle>
                            <EditColumn ButtonType="ImageButton" InsertText="Guardar" UpdateText="Actualizar"
                                        UniqueName="EditCommandColumn1" CancelText="Cancelar">
                            </EditColumn>
                            <FormTableButtonRowStyle HorizontalAlign="Right" BorderStyle="Solid" Font-Bold="True"
                                                     Font-Size="Medium" BorderColor="Black"></FormTableButtonRowStyle>
                        </EditFormSettings>
</MasterTableView>
 
<FilterMenu EnableImageSprites="False"></FilterMenu>
           </telerik:RadGrid>

What I'm trying to do is insert the data in  RadGrid5_InsertCommand but when I try to get the files of radupload control I get no files,
I tried getting the radupload as follows:

           RadUpload upload = (gridEditedItem.EditManager.GetColumnEditor("columna") as GridAttachmentColumnEditor).RadUploadControl;
 
RadUpload upload = (RadUpload)gridEditedItem["columna"].Controls[0];
  In both cases the property InitialFileInputsCount  of upload is equals to 1, but when I try to save upload.UploadedFiles is equals to 0
This is how I try to save  the file
foreach (UploadedFile file in upload.UploadedFiles)
      {
 
          var fileName = idSol + "-" + file.GetName().ToLower();
 
 
          file.SaveAs((@"\\dscvault\doctosAsocCiviles\" + fileName));
 
          urlArchivo = "/doctosAsocCiviles/" + fileName;
 
 
      }
 I can't understand why the uploadedFiles is equals to 0.

Hope your Help.

Best Regards.
Cristian.

1 Answer, 1 is accepted

Sort by
0
Jayesh Goyani
Top achievements
Rank 2
answered on 16 Sep 2013, 06:35 AM
Hello,

If your grid is ajaxify then please remove it or disable ajax on condition base. (Please check "conditionalPostback()" in this link).

You can use RadAsyncUpload to achieve this thing with out postback.


Thanks,
Jayesh Goyani
Tags
Grid
Asked by
Cristian
Top achievements
Rank 1
Answers by
Jayesh Goyani
Top achievements
Rank 2
Share this question
or