Hi Team
I've been following one of your examples where you show a webdialog from a button within a template datafield in a webdatagrid. The example binds the datagrid on each postback.
I would like to do the same thing, but save the datagrid viewstate, so that I don't have to rebind the grid on each postback in the onload event. I want to do this because I have additional buttons that need to rebind the grid on their onclick events and there is no point in binding the grid twice.
When I take your sample and enable dataviewstate on the grid and only bind if not page.ispostback, the eventhandler for the button within the grid is never fired, so the dialog doesn't show.
Is there a way around this, so that clicking the 'info' button on the attached example page will show the dialog? but doing so while not binding the grid on each postback.
regards
Steve
Hellp asdfrog,
Thank you for posting in the community.
I believe the reason for this issue is that templates are not being recreated. What I can suggest for achieving your requirement is to call EnsureTemplates method in the Page_Load event of the page. For example:
protected void Page_Load(object sender, EventArgs e) { this.WebDataGrid1.EnsureTemplates(); }
protected void Page_Load(object sender, EventArgs e)
{
this.WebDataGrid1.EnsureTemplates();
}
I tested this code snippet in your sample and everything worked as expected and the event was correctly fired.
Please test try my suggestion and let me know whether it helps you achieve your requirement.
Thanks for those details Vasya, it now works exactly as expected.
Hello asdfrog,
I am glad that you find my suggestion helpful.
Please feel free to contact me if you need any further assistance with this matter.