This is a migrated thread and some comments may be shown as answers.
RadListBox Reorder changes Text but not the Key
1 Answer 65 Views
This is a migrated thread and some comments may be shown as answers.
Ken Platt
Top achievements
Rank 1
Ken Platt asked on 05 Aug 2009, 11:13 PM

 

When I drag reorder or reorder with the buttons, it works great, but then when I post back via a save button and loop through the items, the Text is in the right order, but the Value is the original value.

So a simple name list
Ken (id 1234)
Brian (id 2345)
Matt (id 3456)

if I reordered Matt to the top, the result during the "SAVE" postback would be:

Matt (id 1234)
Ken (id 2345)
Brian (id 3456)


(notice the IDs have not changed)

Can anyone help??

Here the code.

<
telerik:RadListBox ID="listReorder" Width="250px"

 

 

 

ButtonSettings-VerticalAlign="Middle" Height="300px" AllowReorder="true"

 

 

 

EnableDragAndDrop="true" DataKeyField="PersonID" DataTextField="PersonFullName"

 

 

 

ButtonSettings-ShowReorder="true" runat="server"/>


 

 

protected void btnSave_Click(object sender, EventArgs e)

 

{

 

 

foreach (RadListBoxItem item in listReorder.Items)

 

{
    string fullName =  = item.Text; //LOOKS GOOD

 

 

    int personID = Convert.ToInt32(item.DataKey); //ORIGINAL DATA BOUND VALUE

 

 

 

}
}

 

 

 

1 Answer, 1 is accepted

Sort by
0
Ken Platt
Top achievements
Rank 1
answered on 05 Aug 2009, 11:40 PM
Yeah, so I found the mistake I was making. 

 DataKeyField="PersonID"

should be 

 DataValueField="PersonID"

It may be time for me to take a break...
Asked by
Ken Platt
Top achievements
Rank 1
Answers by
Ken Platt
Top achievements
Rank 1
Share this question
or