ASP.NET Grid Editing
I have a query in regards to a Telerik RadGrid in ASP.NET.
I have a basic List(of BusinessObject) that i have bound to a telerik RadGrid I have enabled the AutoGenerateEditColumn = True and also AllowAutomaticUpdates.
How come it seems so difficult to change a record from a statically bound list from my Grid.
There is a Grid_UpdateCommand Event Handler that allows me to access the changed row by e.Items but i have to cast it to a GridEditableItem instead of my BusinessObject Is this just asp.NET?. Because the record is in memory only i wish to change the value and have the Grid Reflect that value.开发者_运维百科 The tutorials seem convoluted for the task. Im a WPF person myself and find it easy perform this operation in WPF but it just seems crazy that ASP.NET or the Telerik Grid cannot simply change a value of a static record or cast the DataItem as my Custom Business Object.
Please Help
Chris
e.Item is a reference to the grid row, not to the business object. A data bound row is represented by the GridDataItem class, and the edit row by GridEditableItem class. You can access the class you bound by doing:
var obj = ((GridEditableItem)e.Item).DataItem as BusinessObject;
As long as you rebound the grid with data, this will work.
HTH.
精彩评论