ASPForums.Net RSS Feedhttp://www.aspforums.net/Handlers/RSS.ashxLatest additions to the content that appears on ASPForums.Net(c) 2019 www.aspforums.com. All rights reserved.Save uploaded file count using ASP.Net AjaxFileUpload control in C# and VB.Net<p>Hi <a class="username" rel="BugHunter"> BugHunter</a>,</p> <p>You need use UploadCompleteAll event which will give count of uploaded file.</p> <p>Refer below code.</p> <p><span style="text-decoration: underline;"><strong>Namespaces</strong></span></p> <p><strong>C#</strong></p> <pre class="brush: csharp">using System.IO; using AjaxControlToolkit;</pre> <p><strong>VB.Net</strong></p> <pre class="brush: vb">Imports System.IO Imports AjaxControlToolkit</pre> <p><span style="text-decoration: underline;"><strong>Code</strong></span></p> <p><strong>C#</strong></p> <pre class="brush: csharp">static int i = 0; protected void OnUploadComplete(object sender, AjaxFileUploadEventArgs e) { string fileName = Path.GetFileName(e.FileName); AjaxFileUpload11.SaveAs(Server.MapPath(&#34;~/Uploads/&#34; + fileName)); i = i + 1; dtExcelData.Columns.Add(&#34;Cell&#34;).DefaultValue.ToString(); dtExcelData.Columns.Add(&#34;FileCount1&#34;).DefaultValue.ToString(); //Foreach to add in every row in datatable. foreach (DataRow row in dtExcelData.Rows) { row[&#34;Cell&#34;] = Session[&#34;ClientName&#34;].ToString(); row[&#34;FileCount1&#34;] = i; // Uploaded file count. } dtExcelData.Columns[&#34;Cell&#34;].SetOrdinal(0); dtExcelData.Columns[&#34;FileCount1&#34;].SetOrdinal(1); //Bulkinsert method to insert data in sql. InsDataInSql(&#34;File1&#34;, &#34;abcFile1&#34;); }</pre> <p><strong>VB.Net</strong> </p> <pre class="brush: vb">Shared i As Integer = 0 Protected Sub OnUploadComplete(ByVal sender As Object, ByVal e As AjaxFileUploadEventArgs) Dim fileName As String = Path.GetFileName(e.FileName) AjaxFileUpload11.SaveAs(Server.MapPath(&#34;~/Uploads/&#34; &amp; fileName)) i = i + 1 dtExcelData.Columns.Add(&#34;Cell&#34;).DefaultValue.ToString() dtExcelData.Columns.Add(&#34;FileCount1&#34;).DefaultValue.ToString() For Each row As DataRow In dtExcelData.Rows row(&#34;Cell&#34;) = Session(&#34;ClientName&#34;).ToString() row(&#34;FileCount1&#34;) = i Next dtExcelData.Columns(&#34;Cell&#34;).SetOrdinal(0) dtExcelData.Columns(&#34;FileCount1&#34;).SetOrdinal(1) InsDataInSql(&#34;File1&#34;, &#34;abcFile1&#34;) End Sub</pre> <p>&nbsp;</p>https://www.aspforums.net:443/Threads/168746/Save-uploaded-file-count-using-ASPNet-AjaxFileUpload-control-in-C-and-VBNet/https://www.aspforums.net:443/Threads/168746/Save-uploaded-file-count-using-ASPNet-AjaxFileUpload-control-in-C-and-VBNet/Thu, 18 Apr 2019 03:15:47 GMT