Question

When handling the OnUpdateCommand event on a RadGrid the DataItem is null.

I thought that this would also represent the data item being represented by the row.

The Radgrid is populated from an IList and in the handler the code looks like this...

protected void rgAllocatedClients_UpdateCommand(object sender, GridCommandEventArgs e)
{
    if (e.Item is GridDataItem)
    {
        var gridDataItem = e.Item as GridDataItem;
        var client= gridDataItem .DataItem as Client;
        ....
        ....

This works find when handling the ItemDataBound event but not when handling the UpdateCommand event. I really need this as in my Client class is the Id of the row I want to handle the update for.

Thanks,

Was it helpful?

Solution

Try this by using GridEditableItem


 protected void grdContacts_UpdateCommand(object source, Telerik.Web.UI.GridCommandEventArgs e)
    {

        string idEditing = e.Item.OwnerTableView.DataKeyValues[e.Item.ItemIndex]["Id"].ToString();
        GridEditableItem editedItem = e.Item as GridEditableItem;
        Hashtable newValues = new Hashtable();
// ur code
}

OTHER TIPS

Assuming your Grid is in Edit mode befor ethe Update Command, you should cast e.Item to GridEditableItem instead of GridDataItem

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top