How to implement "remove button" function when I create a custom queue table?

Last post 04-23-2009, 9:33 PM by cutechat. 3 replies.
Sort Posts: Previous Next
  •  04-23-2009, 12:52 PM 51445

    How to implement "remove button" function when I create a custom queue table?

    Dear Sir:
     
    When I create a custom queue table, I don't know how to implement a remove function in a custom queue table.
    Could you give me some suggestion ?? Thank you a lot.
     
     
    tmchuang
  •  04-23-2009, 8:01 PM 51467 in reply to 51445

    Re: How to implement "remove button" function when I create a custom queue table?

    tmchuang,
     
    please use list[i].Cancel()
     
    Regards,
    Terry
     
  •  04-23-2009, 8:45 PM 51469 in reply to 51467

    Re: How to implement "remove button" function when I create a custom queue table?

    Dear Terry,
     
    It seem to use javascript to implement and it can't remove the file that I uploaded after I onclick the submit button.
    if I create a custom quene table by build a datalist control, how could I do for it ? Thanks a lot.
     
    Regards,
    tmchuang
     
     
     
  •  04-23-2009, 9:33 PM 51470 in reply to 51469

    Re: How to implement "remove button" function when I create a custom queue table?

    tmchuang,
     
    That should be the 'Attachments' table.
     
    1. <%@ Page Language="C#" %>  
    2. <%@ Register TagPrefix="CuteWebUI" Namespace="CuteWebUI" Assembly="CuteWebUI.AjaxUploader" %>  
    3. <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">  
    4.   
    5. <script runat="server">  
    6.   
    7.     protected override void OnPreRender(EventArgs e)   
    8.     {   
    9.         base.OnPreRender(e);   
    10.   
    11.         //hide the default table   
    12.         UploadAttachments1.GetItemsTable().Visible = false;   
    13.         //bind the grid every times   
    14.         DataGrid1.DataSource = UploadAttachments1.Items;   
    15.         DataGrid1.DataBind();   
    16.         DataGrid1.Visible = UploadAttachments1.Items.Count > 0;   
    17.     }   
    18.        
    19.     protected void DataGrid1_ItemCommand(object sender, System.Web.UI.WebControls.DataGridCommandEventArgs e)   
    20.     {   
    21.         Guid guid = (Guid)DataGrid1.DataKeys[e.Item.ItemIndex];   
    22.         foreach (AttachmentItem item in UploadAttachments1.Items)   
    23.         {   
    24.             if (item.FileGuid == guid)   
    25.             {   
    26.                 if (e.CommandName == "Download")   
    27.                 {   
    28.                     using (Stream str = item.OpenStream())   
    29.                     {   
    30.                         Response.AddHeader("Content-Disposition", "attachment; filename='" + item.FileName+"'");   
    31.                         Response.AddHeader("Content-Length", item.FileSize.ToString());   
    32.                         byte[] buff = new byte[4096];   
    33.                         while (true)   
    34.                         {   
    35.                             int rc = str.Read(buff, 0, buff.Length);   
    36.                             if (rc == 0)   
    37.                                 break;   
    38.                             Response.OutputStream.Write(buff, 0, rc);   
    39.                         }   
    40.                     }   
    41.                 }   
    42.   
    43.                 if (e.CommandName == "Remove")   
    44.                 {   
    45.                     item.Remove();   
    46.                 }   
    47.   
    48.                 break;   
    49.             }   
    50.         }   
    51.     }   
    52.        
    53. </script>  
    54.   
    55. <html xmlns="http://www.w3.org/1999/xhtml">  
    56. <head runat="server">  
    57.     <title>DataGridCS</title>  
    58. </head>  
    59. <body>  
    60.     <form id="form1" runat="server">  
    61.         <div>  
    62.                
    63.             <CuteWebUI:UploadAttachments runat="server" ID="UploadAttachments1" UploadType=Flash>  
    64.             </CuteWebUI:UploadAttachments>  
    65.             <hr />  
    66.             <asp:DataGrid ID="DataGrid1" runat="server" AutoGenerateColumns="false" DataKeyField="FileGuid" OnItemCommand="DataGrid1_ItemCommand">  
    67.                 <Columns>  
    68.                     <asp:BoundColumn DataField="FileGuid" HeaderText="File Guid" />  
    69.                     <asp:BoundColumn DataField="FileName" HeaderText="File Name" />  
    70.                     <asp:BoundColumn DataField="FileSize" HeaderText="File Size" />  
    71.                     <asp:ButtonColumn CommandName="Remove" Text="Remove" />  
    72.                     <asp:ButtonColumn CommandName="Download" Text="Download" />  
    73.                 </Columns>  
    74.             </asp:DataGrid>  
    75.         </div>  
    76.     </form>  
    77.        
    78. </body>  
    79. </html>  
     
    Regards,
    Terry
     
View as RSS news feed in XML