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

Edit button in RadGrid picks the wrong record

2 Answers 129 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Channa Leang
Top achievements
Rank 1
Channa Leang asked on 02 Dec 2010, 03:24 PM
Hi, I need your help with this bug. Here is what I did,

I've a Radgrid (Q1 2010) without any Ajax enabled. And, I've implemented a sorting row function to re-order the items, in which user needs to select a row, and click on a custom-made "Move Up/Down" button located above the RadGrid. Everything is working until I've noticed that, after the sorting is done and I click on the "Edit" button to make some changes to the record. RadGrid picked the wrong record in the Edit mode.

In the HTML source code, I've seen that RadGrid has generated the id of "tr" in order such as,

<tr id="ctl00_ctl00_ContentPlaceHolderBase_ContentPlaceHolder1_RadGrid1_ctl00__0"...
...
<tr id="ctl00_ctl00_ContentPlaceHolderBase_ContentPlaceHolder1_RadGrid1_ctl00__1"...
...
<tr id="ctl00_ctl00_ContentPlaceHolderBase_ContentPlaceHolder1_RadGrid1_ctl00__2"...
...
With my sorting function, the order is messed up. Is it because of that? If so, what is the best way to fix this?

Thanks.

2 Answers, 1 is accepted

Sort by
0
Channa Leang
Top achievements
Rank 1
answered on 02 Dec 2010, 05:05 PM
My temporary solution right now is, after the sorting is done the page will be automatically refreshed. This way the RadGrid will re-index the new sequential items. It works but it's a bit annoying for the user to wait for the page refresh.

However, what I want to achieve is, to make the Edit link button to grab the proper id no matter what if any row is moved up or down.

How to make a custom EditCommand to grab the actual id value instead of ItemIndex ?
0
Veli
Telerik team
answered on 07 Dec 2010, 01:16 PM
Hello Channa,

RadGrid rebinds when you fire Edit command. If your custom row order is not persisted in your database, it is likely that rebinding fetches the grid items in the original order they come from the data source. You need to persist your custom order across rebinds.

You cannot make a custom Edit command without knowing which item should be actually edited. If the item that fires the Edit command is not the item that needs to be edited, how do you know which item should be edited? I believe the problem will be fixed once you find a way to persist your custom order on rebind.

Veli
the Telerik team
Browse the vast support resources we have to jumpstart your development with RadControls for ASP.NET AJAX. See how to integrate our AJAX controls seamlessly in SharePoint 2007/2010 visiting our common SharePoint portal.
Tags
Grid
Asked by
Channa Leang
Top achievements
Rank 1
Answers by
Channa Leang
Top achievements
Rank 1
Veli
Telerik team
Share this question
or