I recently updated to the newest released (2011.1.419.1040), and it has broken the application. I have custom column where i am overriding the CreateCellElement(GridViewCell cell, object dataItem) in there i am calling
((
TextBox)cell.GetEditingElement()).Text to update the text value, and now i am getting null reference exception. This was working in the previous release. Does anyoen know the workaround for it?
Thanks,
Amit
6 Answers, 1 is accepted
In order to provide you with a more suitable solution, I would need slightly more details. May you share more information about the exact definition of your custom column ? Furthermore, may you verify whether you are getting the same null result for other cells too or just for those of your custom column ?
Maya
the Telerik team
public sealed class GridViewDistributionColumn : GridViewDataColumn
{
public override FrameworkElement CreateCellElement(GridViewCell cell, object dataItem)
{
var button = new Button();
button.Content =
"Click Me!";
button.Click += (sender, e) => cell.BeginEdit();
return button;
}
}
Thanks,
Terry
If the general purpose is to put the corresponding cell into edit mode, you have to define DataMemberBinding or CellEditElement() / CellEditTemplate. Basically, the reason for you to get null from GetEditingElement() would be that no edit element is created.
Please let me know in case you need any further assistance.
Maya
the Telerik team
Thanks,
Terry
Indeed, you are quite right - the behavior you mentioned has been changed since Q2 2010 SP2. With the current version you may set the IsTabStop property of the Button to false:
var button = new Button();
button.Content = "Click Me!";
button.IsTabStop = false;
Kind regards,
Maya
the Telerik team
Terry