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

Retrieve updated values from a Grid

1 Answer 89 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Paul
Top achievements
Rank 1
Paul asked on 19 Jul 2011, 09:41 AM
I have a simple generic list
List<WrapperViewModel> viewModels = new List<WrapperViewModel>();
 
viewModels.Add(new WrapperViewModel("Paul", 45));
viewModels.Add(new WrapperViewModel("Hannah", 36));
viewModels.Add(new WrapperViewModel("Joshua", 22));
viewModels.Add(new WrapperViewModel("Tissie", 6));
 
which I bind to a grid. I let the grid generate the columns. On the PreRender, I set everything to edit
foreach (GridDataItem item in RadGrid1.Items)
{
    item.Edit = true;
}

And my grid appears with my data in it, although annoyingly, the last row is selected.

If I change a value in the Grid, how do I get the updated value back at the server? If I access the grid items DataItem, it is always null. I was expecting the DataItem to be a regenerated version of the object I originally did the bind with. I've been following threads around but I still cannot get this simple scenario to work. The MVC demo web site has a new feature 'Keyboard Navigation' which shows the kind of behavior I want.

Anyone got a working sample?


1 Answer, 1 is accepted

Sort by
0
Iana Tsolova
Telerik team
answered on 22 Jul 2011, 09:51 AM
Hi Paul,

Do you mean that only the last item is in edit mode? If so, make sure that you have enabled multi-row editing:
<telerik:RadGrid ID="RadGrid1" runat="server" AllowMultiRowEdit="true">

On how to get the values: You can refer to the below article and try the demo attached to this post.
http://www.telerik.com/help/aspnet-ajax/grid-performing-batch-updates.html

Additionally, the Radgrid for ASP.NET AJAX has keyboard navigation with a lot of features. Check the demo for more infromation:
http://demos.telerik.com/aspnet-ajax/grid/examples/client/keyboardnavigation/defaultcs.aspx

Best wishes,
Iana
the Telerik team

Register for the Q2 2011 What's New Webinar Week. Mark your calendar for the week starting July 18th and book your seat for a walk through of all the exciting stuff we will ship with the new release!

Tags
Grid
Asked by
Paul
Top achievements
Rank 1
Answers by
Iana Tsolova
Telerik team
Share this question
or