RadAsyncUpload unable to persist data for asp:Repeater

5 posts, 0 answers
  1. Benjamin
    Benjamin avatar
    61 posts
    Member since:
    Jul 2016

    Posted 18 Nov 2016 Link to this post

    Hi. i am trying to form for user to type in the name of their course. then each of this course will be able to upload multiple files. 

    for example user type Computer Engineering, then they are able to upload multiple files for this Computer Engineering. i have tried to do a sample test page to try out the control. but when i click on the Add to add a row to repeater, the previously uploaded data got lost.

     

    Markup:

    01.<asp:UpdatePanel ID="pnlEntryTemplate1" runat="server" UpdateMode="Conditional">
    02.    <ContentTemplate>
    03.        <asp:Repeater ID="rptReplyDate" runat="server" OnItemCommand="rptReplyDate_ItemCommand">
    04.            <HeaderTemplate>
    05.                <table cellpadding="0px" cellspacing="0px">
    06.            </HeaderTemplate>
    07.            <FooterTemplate>
    08.                    <tr>
    09.                        <td style="padding: 1em 1em;" align="right">
    10.                            <asp:Button ID="btnAddEntry" runat="server" Text="Add Entry" OnClick="btnAddEntry_Click" />
    11.                        </td>
    12.                    </tr>
    13.                </table>
    14.            </FooterTemplate>
    15.            <ItemTemplate>
    16.                <tr>
    17.                    <td style="padding: 1em 1em;">
    18.                        <table cellpadding="0px" cellspacing="0px" class="repeaterTable">
    19.                            <tr>
    20.                                <td>
    21.                                    <asp:TextBox ID="txtName" ClientIDMode="Static" runat="server" Text='<%# DataBinder.Eval(Container.DataItem, "txtName") %>'></asp:TextBox>
    22.                                </td>
    23.                            </tr>
    24.                            <tr>
    25.                                <td>
    26.                                    <telerik:RadAsyncUpload ID="RadAsyncUpload1" runat="server" PostbackTriggers="btn_Submit"></telerik:RadAsyncUpload>
    27.                                </td>
    28.                            </tr>
    29.                        </table>
    30.                    </td>
    31.                </tr>
    32.            </ItemTemplate>
    33.        </asp:Repeater>
    34.    </ContentTemplate>
    35.</asp:UpdatePanel>
    36.<asp:Button ID="btn_Submit" runat="server" Text="Submit" OnClick="btn_Submit_Click" />
  2. Benjamin
    Benjamin avatar
    61 posts
    Member since:
    Jul 2016

    Posted 18 Nov 2016 in reply to Benjamin Link to this post

    i understand that when i add the control the repeater rebind. so now how do i set back the files back to the asyncupload control

     

    current code when btn_add is click to add the row

    01.protected void btnAddEntry_Click(object sender, EventArgs e)
    02.{
    03.    List<ReplayDate> col = new List<ReplayDate>();
    04.     foreach(RepeaterItem item in rptReplyDate.Items)
    05.     {
    06.            ReplayDate data = new ReplayDate();
    07.            data.txtName = ((TextBox)item.FindControl("txtName")).Text;
    08.            data.files = ((RadAsyncUpload)item.FindControl("RadAsyncUpload1")).UploadedFiles;
    09.            col.Add(data);
    10.     }
    11.     ReplayDate newData = new ReplayDate();
    12.     rptReplyDate.DataSource = col;
    13.     rptReplyDate.DataBind();
    14.}
    15. 
    16.public class ReplayDate
    17.{
    18.    public int id { get; set; }
    19.    public string txtName { get; set; }
    20.    public UploadedFileCollection files { get; set; }
    21.}
  3. Veselin Tsvetanov
    Admin
    Veselin Tsvetanov avatar
    466 posts

    Posted 18 Nov 2016 Link to this post

    Hi Benjamin,

    I am afraid that you won't be able to repopulate the RadAsyncUpload control after the Repeater control has been rebound. To achieve the desired functionality, I would suggest you not to use Repeater, but a simple Panel control and append the newly added controls to its controls collection.

    Regards,
    Veselin Tsvetanov
    Telerik by Progress
    Telerik UI for ASP.NET AJAX is ready for Visual Studio 2017 RC! Learn more.
  4. Benjamin
    Benjamin avatar
    61 posts
    Member since:
    Jul 2016

    Posted 18 Nov 2016 in reply to Veselin Tsvetanov Link to this post

    Hi Veselin. thanks for the reply. as this is my 1st time adding dynamic control without using asp:Repeater. it is possible for u to provide some simple sample code or demo to refer to?
  5. Veselin Tsvetanov
    Admin
    Veselin Tsvetanov avatar
    466 posts

    Posted 23 Nov 2016 Link to this post

    Hello Benjamin,

    I would suggest you to review the following MSDN article demonstrating how to add controls from the code behind to the Controls collection of a asp:Panel.

    Note that you will have to add the newly created panel to an existing panel on the page:
    PanelPlaceholder.Controls.Add(Panel1);

    Regards,
    Veselin Tsvetanov
    Telerik by Progress
    Telerik UI for ASP.NET AJAX is ready for Visual Studio 2017 RC! Learn more.
Back to Top