Telerik RadGrid: how do I add a new row from code behind?
What's开发者_开发百科 the simplest way to add a new row to a Telerik RadGrid in ASP.NET from code behind?
If you add a new item in the grid source and rebind the grid, this should do the trick (since the Telerik grid is data-bound control). To display the insertion form, set the MasterTableView.IsItemInserted property to true.
Dick
The basics of adding a row are described in this demo from Telerik's website. Generally though, through the code behind, there are a few method that I've found that you need to make a telerik grid work:
- RadGrid1_NeedDataSource - used for paging and on_load events
- RadGrid1_UpdateCommand - updating a row
- RadGrid1_ItemDataBound - bindingto a row item
RadGrid1_RemoveCommand - removing a row item
GridEditableItem editedItem = e.Item as GridEditableItem;
Wil give you access to a row item. And:
editedItem.GetDataKeyValue()
will give you access to an id associted with each row item.
Good luck, and hope this helps out some.
精彩评论