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.