Telerik Radgrid GridDataItem.DataItem is empty on update (OnUpdateCommand handler)

When handling the OnUpdateCommand event in the RadGrid, the DataItem is null.

I thought this would also represent the data item represented by the string.

Radgrid is filled from 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 when handling the ItemDataBound event, but not when handling the UpdateCommand event. I really need this since my Client class has the Id of the row that I want to handle the update with.

Thanks,

+2


a source to share


2 answers


Try this with 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
}

      

+1


a source


Assuming your grid is in edit mode for the update command, you should use e.Item for the GridEditableItem instead of GridDataItem



+2


a source







All Articles