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

[Solved] e.item["field"] comes back empty

3 Answers 61 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Regino Sanchez
Top achievements
Rank 1
Regino Sanchez asked on 04 Feb 2010, 05:38 PM
Hello,
I am using the error handler example linked here:

http://www.telerik.com/help/aspnet/grid/grderrorhandling.html


The code runs fine, but it does not return a vaule for the field, it returns &nbsp rather than the key value. Correct values are displayed in the grid.

Any advice would be appreciated.




3 Answers, 1 is accepted

Sort by
0
Daniel
Telerik team
answered on 04 Feb 2010, 06:46 PM
Hello Regino,

I recommend you try to extract the value from the item rather than using the cell text.
protected void RadGrid1_ItemUpdated(object source, Telerik.Web.UI.GridUpdatedEventArgs e)
{
    Hashtable values = new Hashtable();
    GridEditableItem item = e.Item as GridEditableItem;
    item.ExtractValues(values);
 
    if (e.Exception != null)
    {
        e.KeepInEditMode = true;
        e.ExceptionHandled = true;
        DisplayMessage("Category " + values["CategoryName"].ToString() + " cannot be updated. Reason: " + e.Exception.Message);
    }
    else
    {
        DisplayMessage("Category " + values["CategoryName"].ToString() + " updated");
    }
}

Best regards,
Daniel
the Telerik team

Watch a video on how to optimize your support resource searches and check out more tips on the blogs.
Follow the status of features or bugs in PITS and vote for them to affect their priority.
0
Regino Sanchez
Top achievements
Rank 1
answered on 04 Feb 2010, 07:37 PM
Daniel,
thank you for the quick reply; the problem with using hash table is that in only returns visible columns and the key needs to remain hidden.

0
Princy
Top achievements
Rank 2
answered on 05 Feb 2010, 10:16 AM
Hi,

Have you tried accessing the Key field using the GetDataKeyValue method from the GridEditableItem.

string key = item.GetDataKeyValue("EmployeeID").ToString();

Thanks,
Princy
Tags
Grid
Asked by
Regino Sanchez
Top achievements
Rank 1
Answers by
Daniel
Telerik team
Regino Sanchez
Top achievements
Rank 1
Princy
Top achievements
Rank 2
Share this question
or