0

I'm using ASPxUploadControl inside EditItemTemplate in ASPxGridView. When I click on edit row button the ASPxUploadControl is shown, if not in edit mode it acts as a hyperlink column and show the download file option. The issue I'm facing is that I'm not getting the control object in the Insertion and Updation event of ASPxGridView.

I' doing something like this

ASPxUploadControl = grid.FindEditRowCellTemplate(grid.Columns[0] as GridViewDataColumn, "upload_control_id") as ASPxUploadControl;

I've also tried grid.FindControl() function.

sms247
  • 4,404
  • 5
  • 35
  • 45

2 Answers2

0

Try this for Edit Refer This

protected void ASPxUploadControl1_FilesUploadComplete(object sender, DevExpress.Web.ASPxUploadControl.FilesUploadCompleteEventArgs e){
    // Intentionally pauses server-side processing to demonstrate the Loading Panel or Progress Panel functionality
    System.Threading.Thread.Sleep(2000);

    ASPxUploadControl uploadControl = sender as ASPxUploadControl;

    if (uploadControl.UploadedFiles != null && uploadControl.UploadedFiles.Length > 0){
        for (int i = 0; i < uploadControl.UploadedFiles.Length; i++){
            UploadedFile file = uploadControl.UploadedFiles[i];
            if (file.FileName != ""){
                string fileName = string.Format("{0}{1}", MapPath("~/Images/"), file.FileName);
                //file.SaveAs(fileName, true);//OnLine Demo Restriction
            }
        }
    }
}
Amol
  • 1,431
  • 2
  • 18
  • 32
0

On Update or Insert event, get the GridView to find the get it's template control.

ASPxGridView gridView = sender as ASPxGridView;
ASPxUploadControl control = gridView.FindEditRowCellTemplateControl(gridView.Columns[0] as GridViewDataColumn, "upload_control_id") as ASPxUploadControl;

References:
find control update edititemtemplate
ASPxGridView - How to find a control inside the EditItemTemplate
ASPxGridView - How to find a control in EditItemTemplate
How to programmatically reach any AspxControl inside an AspXGridView's EditItemTemplate
ASPxGridView Find control (Checkbox) and Check if it is checked or not

example code snippet:

Protected Sub grid_RowInserting(ByVal sender As Object, ByVal e As DevExpress.Web.Data.ASPxDataInsertingEventArgs) Handles grdProyectos.RowInserting
        Dim grid As ASPxGridView = (TryCast(sender, ASPxGridView))
        Dim chk As CheckBox= grid.FindEditRowCellTemplateControl(grid.Columns("name_colum"), "nameCheckBox")
        Dim marcada as Boolean = chk.Checked
End Sub
Community
  • 1
  • 1
Niranjan Singh
  • 18,017
  • 2
  • 42
  • 75