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

Picking up text and values from transferred ListBox

1 Answer 109 Views
ListBox
This is a migrated thread and some comments may be shown as answers.
nightvision miami
Top achievements
Rank 1
nightvision miami asked on 22 Apr 2010, 04:13 PM

I am working with VS 2008 with ASP.NET AJAX Q1 2010 ListBox control.

Code in my ASPX page

<telerik:RadListBox ID="radRotationSource" runat="server" AllowTransfer="True"   
                            style="width: 200px" TransferMode="Copy"   
                            TransferToID="radRotationDestination" Skin="Windows7">  
<ButtonSettings ReorderButtons="Common"></ButtonSettings> 
                        </telerik:RadListBox>    
                        <telerik:RadListBox ID="radRotationDestination" runat="server"   
                            style="width: 200px" Skin="Windows7">  
                            <ButtonSettings ReorderButtons="Common">  
                            </ButtonSettings> 
                        </telerik:RadListBox> 

C# Code to load Source RadListBox
            Database db = null;  
 
            db = DatabaseFactory.CreateDatabase();  
            DataSet ds = db.ExecuteDataSet(CommandType.StoredProcedure, "GetAllUsersForRotation");  
            db = null;  
            radRotationSource.DataSource = ds;  
            radRotationSource.DataTextField = "Login";  
            radRotationSource.DataValueField = "UserID";  
            radRotationSource.DataBind();  
            radRotationSource.Sort = Telerik.Web.UI.RadListBoxSort.Ascending;  
            radRotationSource.SortItems();    

C# Code to Save values from Destination RadListBox
        protected void btnSave_Click(object sender, EventArgs e)  
        {  
            Database db = null;  
 
            db = DatabaseFactory.CreateDatabase();  
 
            int rows = db.ExecuteNonQuery(CommandType.StoredProcedure, "ClearUsersInRotation");  
 
            string[] arr = new string[2];  
 
            for (int x = 1; x < radRotationDestination.Items.Count; x++)  
            {  
                arr[0] = radRotationDestination.Items[x].DataItem.ToString();  
                arr[1] = radRotationDestination.Items[x].DataKey.ToString();  
                rows = db.ExecuteNonQuery("SetUsersInRotation", arr);  
            }  
 
            db = null;  
        } 

The code for loading up the Source RadListBox works fine and I have all the users correctly and I am able to transfer them using the buttons over to the Destination RadListBox.  The problem is when I click on the SAVE button and want to grab the DataValueField and the position of each item in the Destination RadListBox and store it in the database, I have no values.

1 Answer, 1 is accepted

Sort by
0
nightvision miami
Top achievements
Rank 1
answered on 23 Apr 2010, 01:44 PM
Fixed issue.  Problem was postback.
Tags
ListBox
Asked by
nightvision miami
Top achievements
Rank 1
Answers by
nightvision miami
Top achievements
Rank 1
Share this question
or