Hi guys,
We just wanted to let you know, that we've added one more project to show you how to export from withing MS UpdatePanel, when the control is in RadGridTemplateColumn or in the CommandItemTemplate. Avoiding ajaxification from MS UpdatePanel is easy considering the control in question is available directly on the page by setting it declaratively as PostBackTrigger. However when in Template control, you cannot do that declaratively and need to locate and access it on the server. According to the
MS AJAX documentation adding PostBackTrigger control programmatically is not supported, however you can use the RegisterPostBackControl() method of the ScriptManager for this purpose. Here is the code we've used in the example:
protected void RadGrid1_ItemCreated(object sender, GridItemEventArgs e) |
{ |
if (e.Item is GridDataItem) |
{ |
Button btn = (e.Item as GridDataItem)["TemplateColumn"].FindControl("Button1") as Button; |
ScriptManager1.RegisterPostBackControl(btn); |
} |
if (e.Item is GridCommandItem) |
{ |
Button btncmd = (e.Item as GridCommandItem).FindControl("btnExcel") as Button; |
ScriptManager1.RegisterPostBackControl(btncmd); |
|
btncmd = (e.Item as GridCommandItem).FindControl("btnWord") as Button; |
ScriptManager1.RegisterPostBackControl(btncmd); |
|
btncmd = (e.Item as GridCommandItem).FindControl("btnCSV") as Button; |
ScriptManager1.RegisterPostBackControl(btncmd); |
|
btncmd = (e.Item as GridCommandItem).FindControl("btnPDF") as Button; |
ScriptManager1.RegisterPostBackControl(btncmd); |
} |
} |
Best regards,
Steve
the Telerik team