Re: How to stop autopostback after selecting multiple files

  •  09-03-2012, 8:25 AM

    Re: How to stop autopostback after selecting multiple files

    Hi ChetanRajakumar,

     

    Please try the example below. In the example below, I check the file name which with string 'a', and add it for the datalist control. You can use the same code to check the file name from your database.

     

    1. <%@ Page Language="C#" AutoEventWireup="True" %>  
    2.   
    3. <%@ Register TagPrefix="CuteWebUI" Namespace="CuteWebUI" Assembly="CuteWebUI.AjaxUploader" %>  
    4. <%@ Import Namespace="System.Data" %>  
    5. <html>  
    6.   
    7. <script runat="server">  
    8.   
    9.     ICollection CreateDataSource(ArrayList files)  
    10.     {  
    11.         DataTable dt = new DataTable();  
    12.         DataRow dr;  
    13.         dt.Columns.Add(new DataColumn("FileName"typeof(String)));  
    14.         for (int i = 0; i < files.Count; i++)  
    15.         {  
    16.             dr = dt.NewRow();  
    17.             dr[0] = files[i].ToString();  
    18.             dt.Rows.Add(dr);  
    19.         }  
    20.         DataView dv = new DataView(dt);  
    21.         return dv;  
    22.     }  
    23.     protected void uploader1_UploadCompleted(object sender, UploaderEventArgs[] args)  
    24.     {  
    25.   
    26.         ArrayList files = new ArrayList();  
    27.         for (int i = 0; i < args.Length; i++)  
    28.         {  
    29.             //check the exists file names here  
    30.             if (args[i].FileName.IndexOf("a") != -1)  
    31.             {  
    32.                 //Compared with the database file name  
    33.                 //if file exists, add into the ArrayList  
    34.                 files.Add(args[i].FileName);  
    35.             }  
    36.   
    37.         }  
    38.         //generate the data source  
    39.         ItemsList.DataSource = CreateDataSource(files);  
    40.         ItemsList.DataBind();  
    41.     }  
    42.   
    43.   
    44. </script>  
    45.   
    46. <body>  
    47.     <form id="Form1" runat="server">  
    48.         <CuteWebUI:Uploader ID="uploader1" runat="server" MultipleFilesUpload="true" OnUploadCompleted="uploader1_UploadCompleted" InsertText="select multiple files">  
    49.         </CuteWebUI:Uploader>  
    50.         <asp:DataList ID="ItemsList" RepeatDirection="Vertical" RepeatLayout="Table" runat="server">  
    51.             <ItemTemplate>  
    52.                 file name:  
    53.                 <%# DataBinder.Eval(Container.DataItem, "FileName")%>  
    54.             </ItemTemplate>  
    55.         </asp:DataList>  
    56.     </form>  
    57. </body>  
    58. </html>  
     

     

    Regards,

     

    Ken 

View Complete Thread