Since the version 14.1.20141.2283 upgrade, clicking a link button inside a Template Item does not fire the ItemCommand method when a webdatagrid is set to EnableDataViewState="true". If I set EnableDataViewState="false" and rebind the grid each postback the ItemCommand method fires as expected. This behavior was not occurring in the previous version of 14.1. Is this a known error? How can I fix it with rebinding my grids on each postback?
Hello droedger,
The reason that the ItemCommand event is failing to fire is that templates of the grid are instantiated in the DataBind method of the grid. Normally if this method is not manually called it gets called during the OnPreRender event for the grid. However, when using this with the ItemCommand the DataBind event is fired after the ItemCommand event is supposed to fire. Since the templates haven't been instantiated in time the event can't find the templates and fails out silently.The way to resolve this issue is to ensure that the templates exist. You can do this by adding the following code to your PageLoad event:if (IsPostBack) {
WebDataGrid1.EnsureTemplates();}The way that it was working previously in the older versions was not actually the intended behavior of the control. This new approach is the correct way to implement ItemCommands, TemplateColumns, and EnableDataViewState. Please let me know if you have any questions or concerns about this approach, or let me know if I may be of any other help.
Thank you!!!! I just spent 3 hours trying to track down why this stopped working properly in 14.2. Numerous Google searches through me off track and I tried numerous "tricks" to no avail. This simple line...added to my existing code...fixed everything.