I am dynamically creating dragrids in different rows of an existing datagrid in asp.NET
My generated datagrids have a column which is TemplateColumn (a CheckBox Column).
In my parent datagrid, I have a template column with checkboxes. when I check or uncheck the value of the check box, the check_change method is called (autopostback is set to true), the dynamically generated datagrids lose the checked checkboxes (the checkboxes are all unchecked again). However, if i check any of the checkboxes of the child (dynamically generated) grids and press F5, it refreshes the page but still I have my checked checkboxes.
What’s happening ?? how is post-back different from refresh F5??? understanding this might help me fix my problem here :DataGrid not being altered!
It’s simple, the browser caches the response. So if you press F5, you’d generally see your grid with the checked checkboxes each time. But if you do a post-back in code, you force the browser to connect to the server and post the data.
It will then wait for a response from the server, and return whatever the reason for the post-back was.
Annoying, but that’s how browsers work. You can force a complete refresh than emulates a post-back by hitting Ctrl+F5.
This is (sometimes) browser dependent because not all browsers will act the same as you described here.
If a post-back is necessary but you still want to keep the checkbox status as checked, I’d recommend an AJAX call instead.