How do I transfer listbox Items during processing?

4 posts, 0 answers
  1. David
    David avatar
    25 posts
    Member since:
    Oct 2010

    Posted 31 Aug 2011 Link to this post

    I am writing some C# code that transfers data from files into a database. I show the files to be processed in one list box and once processed I wish to transfer it from that listbox to another. Unfortunately it doesn't show any of the moves until after all the processing is completed. Can anyone show me what I am doing wrong?

    <telerik:RadAjaxPanel ID="RP1" runat="server" Width="100%">
              
            <br />
            <table class="style2">
                <tr>
                    <td align="center" width="33%">
                        <asp:Label ID="lblUpload" runat="server" ForeColor="#000099" Text="Uploaded" Visible="False"></asp:Label>
                    </td>
                    <td align="center" width="33%">
                         </td>
                    <td align="center" width="33%">
                        <asp:Label ID="lblProcessed" runat="server" ForeColor="#000099" Text="Imported" Visible="False"></asp:Label>
                    </td>
                </tr>
                <tr>
                    <td align="center" valign="top" width="50%">
                        <telerik:RadListBox ID="UploadListBox" runat="server" Visible="False" Width="350px"
                            AllowDelete="True" TransferToID="ProcessedListBox">
                            <ButtonSettings TransferButtons="All"></ButtonSettings>
                        </telerik:RadListBox>
                    </td>
                    <td align="center" valign="top" width="50%">
                        <telerik:RadButton ID="RadButton1" runat="server" onclick="RadButton1_Click" 
                            Text="Transfer to Database">
                        </telerik:RadButton>
                    </td>
                    <td align="center" valign="top" width="50%">
                        <telerik:RadListBox ID="ProcessedListBox" runat="server" Visible="False" Width="350px">
                            <ButtonSettings TransferButtons="All"></ButtonSettings>
                        </telerik:RadListBox>
                    </td>
                </tr>
            </table>
            </telerik:RadAjaxPanel>

    C#

    protected void RadButton1_Click(object sender, EventArgs e)
        {
            {
      
                int tcount = UploadListBox.Items.Count;
                if (tcount < 1)
                {
                    lblMessage.Text= "You must have files to process.";
                    return;
                }
                int increment = 100 / tcount;
                int completed = 0;
                string pfile;
                string[] fileparts;
                for (int i = 0; i < (tcount); i++)
                {
                    string filetype;
                    InitMstrVariables();
                    InitFGVariables();
                    InitTransactionSet();
                    pfile = UploadListBox.Items[0].Value.ToString();
                    fileparts = pfile.Split('_');
                    MstrType = Right(fileparts[1], 1).ToUpper();
                    Batch = Convert.ToInt32(fileparts[0]);
                    MstrYearMonth = Convert.ToInt32(Left(fileparts[3], 6));
                    DateCreated = StrToDate(fileparts[3]);
                    filetype = Left(fileparts[1], 3);
                    if (filetype == "834")
                    {
                        DeleteBatch834();
                        ProcessFile834(pfile);
                    }
                    else if (filetype == "820")
                    {
                        DeleteBatch820();
                        ProcessFile820(pfile);
                    }
                    var item = new Telerik.Web.UI.RadListBoxItem();
                    item.Value = pfile;
                    item.Text = pfile;
                    UploadListBox.Transfer(UploadListBox.Items[0], UploadListBox, ProcessedListBox);
                    File.Delete(filepath + pfile);
                    completed = completed + increment;
                }
            }
        }


    This is really bugging me. :)
  2. Princy
    Princy avatar
    17421 posts
    Member since:
    Mar 2007

    Posted 02 Sep 2011 Link to this post

    Hello David,

    Take a look at the following demo.
    ListBox / Transfer.

    Thanks,
    Princy.
  3. UI for ASP.NET Ajax is Ready for VS 2017
  4. David
    David avatar
    25 posts
    Member since:
    Oct 2010

    Posted 02 Sep 2011 Link to this post

    Hi,

    I forgot I had started an older thread on this. I'm still having a problem though.

    http://www.telerik.com/community/forums/aspnet-ajax/listbox/moving-items-from-one-listbox-to-another-during-server-side-event.aspx

  5. Dimitar Terziev
    Admin
    Dimitar Terziev avatar
    1266 posts

    Posted 06 Sep 2011 Link to this post

    Hi David,

    I'm closing this thread for now and we will continue the discussion in this one here.

    Regards,
    Dimitar Terziev
    the Telerik team

    Thank you for being the most amazing .NET community! Your unfailing support is what helps us charge forward! We'd appreciate your vote for Telerik in this year's DevProConnections Awards. We are competing in mind-blowing 20 categories and every vote counts! VOTE for Telerik NOW >>

Back to Top