This is a migrated thread and some comments may be shown as answers.

How do I transfer listbox Items during processing?

3 Answers 81 Views
ListBox
This is a migrated thread and some comments may be shown as answers.
David
Top achievements
Rank 1
David asked on 31 Aug 2011, 05:54 PM
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. :)

3 Answers, 1 is accepted

Sort by
0
Princy
Top achievements
Rank 2
answered on 02 Sep 2011, 02:09 PM
Hello David,

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

Thanks,
Princy.
0
David
Top achievements
Rank 1
answered on 02 Sep 2011, 05:06 PM
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

0
Dimitar Terziev
Telerik team
answered on 06 Sep 2011, 12:07 PM
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 >>

Tags
ListBox
Asked by
David
Top achievements
Rank 1
Answers by
Princy
Top achievements
Rank 2
David
Top achievements
Rank 1
Dimitar Terziev
Telerik team
Share this question
or