Hi there!
Please following steps:
1. My example have one DropDownList and one WebDataGrid. I set AutoPostBack = True for the DropDownList.
2. In this scenario, when I change item of DropDownList then the WebDataGrid will be reloading with new DataSource.
3. First of all, I change values of any cells on the grid, then I change item of DropDownList, an error has occurred like this:
I have tried ClearDatasource() before ReBind() the DataSource of WebDataGrid, but this could not resolved the error.
I'm using NetAdvantage 14.1.20141.2150 lastest released.
Please help me out of this problem.
Best regard, Slim.
Hello and welcome to the community,
When CRUD operations are handled, it is required the WebDataGrid to have access to the DataSource the modified records were a part of. If the grid’s DataSource is changed before the CRUD operations events are fired, at the time they do the grid has a different DataSource hence the CRUD operations cannot be completed and an exception fires. You could a handler for the updating/put a breakpoint and see when it is hit. SelectedIndexChanged event of the dropdownlist fires first, before CRUD operations. At this point "Requested record cannot be found" exception will be raised.
You could use a session variable in order to persist the current DataSource used. On each Page_Load, the grid can be rebound to the same DataSource to which it was bound last (on a previous postback), to ensure that grid updates can be handled accordingly. On the dropdown list’s SelectedIndexChanged the grid is not bound to the new DataSource. Instead, the grid is rebound to the new DataSource (and the current DataSource session variable is updated) at the PreRender stage, when all CRUD operations have already been handled.
Please let me know if you require additional assistance!
Hello Ivaylo,
Thanks for your suggestion.
Regards,
Slim
Could you please elaborate on how to do the above suggested solution with codes and examples...