Subin Thomas

Subin Thomas

  • NA
  • 4.9k
  • 125.9k

multiple file upload in entity framework !

Jun 18 2019 3:10 AM
i have a code which accepts multiple file on gridview but when clickd on save it is taking only 1 file
 
  1. protected void btnUpload_Click(object sender, EventArgs e)  
  2.    {  
  3.        try  
  4.        {  
  5.            ddlBillType_DataBound(ddlBillType, e);  
  6.          
  7.   
  8.            DataTable dtDoc = new DataTable();  
  9.              
  10.          
  11.            if (dtDoc.Rows.Count < 0)
  12.            {  
  13.                
  14.           
  15.                dtDoc = objTrnFVCBillAction.GetBlankDocumentListDataTable();  
  16.                ViewState["dtAddDoc"] = dtDoc;  
  17.                lblAutoDocID.Text = "0";  
  18.                  
  19.            }  
  20.            else  
  21.            {  
  22.                dtDoc = (DataTable)ViewState["dtAddDoc"];  
  23.              
  24.            }  
  25.              
  26.   
  27.            if (ddlDocumentName.SelectedValue != "0" && fuSupDocs.FileName != "")  
  28.            {  
  29.                DataRow dr = dtDoc.NewRow();  
  30.   
  31.   
  32.                btnUpload.EnableViewState = true;  
  33.   
  34.                if (btnUpload.Text == "Add Document")  
  35.                {  
  36.                    if (lblAutoDocID.Text == "")  
  37.                    {  
  38.                        lblAutoDocID.Text = "0";  
  39.                    }  
  40.   
  41.                    lblAutoDocID.Text = (long.Parse(lblAutoDocID.Text) + 1).ToString();  
  42.   
  43.                    dr[Constant.Auto_Gen_ID] = long.Parse(lblAutoDocID.Text);  
  44.                }  
  45.                dr["Document_Name"] = ddlDocumentName.SelectedItem.Text;  
  46.   
  47.                if (fuSupDocs.HasFile)  
  48.                {  
  49.                     
  50.                        dr["Document_Name"] = fuSupDocs.PostedFile.FileName;  
  51.                      
  52.                        string sFileName = string.Empty;  
  53.                         
  54.   
  55.                        sFileName = Server.MapPath(@"~/Temp/" + fuSupDocs.FileName);  
  56.                        fuSupDocs.SaveAs(sFileName);  
  57.   
  58.                        dr["Document_URL"] = sFileName;  
  59.                     
  60.                }  
  61.                if (btnUpload.Text == "Add Document")  
  62.                {  
  63.   
  64.                    dtDoc.Rows.Add(dr);  
  65.                    ViewState["dtAddDoc"] = dtDoc;  
  66.                  
  67.                    grdSuppDocs.DataSource = dtDoc;  
  68.                    grdSuppDocs.DataBind();  
  69.                    BlankDoc();  
  70.                }  
  71.            }  
  72.        }  
  73.        catch (Exception ex)  
  74.        {  
  75.            Omb.ShowMessage(ex.Message, true);  
  76.        }  
  77.    } 
action page code
 
  1. public DataTable GetBlankDocumentListDataTable()  
  2.      {  
  3.          DataTable dtDocVoucher = new DataTable();  
  4.          dtDocVoucher.Columns.Add(Constant.Auto_Gen_ID, System.Type.GetType("System.Int64"));  
  5.          dtDocVoucher.Columns.Add("Document_Name", Type.GetType("System.String"));  
  6.          dtDocVoucher.Columns.Add("Document_URL", Type.GetType("System.String"));  
  7.   
  8.          return dtDocVoucher;  
  9.      } 
 

Answers (1)