I have a RadGrid in a page which has a master page with an UpdatePanel wrapped round the Content.
I have successfully run RegisterPostbackControl for the Export buttons on it on first load, thus:
Private Sub uxGrid_ItemCreated(ByVal sender As Object,
ByVal e As GridItemEventArgs)
If TypeOf e.Item Is GridCommandItem Then
Dim sc As ScriptManager = CType(Master.FindControl("Sc"), ScriptManager)
RegisterPostBackControl(e.Item.FindControl("ExportToCSVButton"))
End If
End Sub
This works, and if I press the export button it does a full postback and exports a file.
I have another control on that page (a date control), which changes the content of the grid, and that posts back asychronously.
The trouble is, once I’ve done one asynchronous postback, I cannot register the control again, and the export button no longer fires a full postback. I have tried putting the RegisterPostback in as many different places as I can think of – RenderComplete, Init, Load, PreRender, etc, but it seems to no avail. Once it’s in an asynch postback, I cannot register it.
Some other code I tried:
For Each cmdItem As GridCommandItem In
uxResponse.MasterTableView.GetItems(GridItemType.CommandItem)
sc.RegisterPostBackControl(cmdItem.FindControl("ExportToCSVButton"))
I know I can switch off asynchronous postback altogether, but I’d much rather have the responsiveness, and this is the only thing which is broken.
Has anyone else had this problem and sorted it?
I sorted this by bypassing the problem: I amended the aspx page to have an export button on it all the time (not dynamically created), registered that for postback, and used CSS to put the new button in the same place as the old button.
Not particularly nice, but it works as a kludge.
If no-one knows a better way, I’ll mark this as the answer in a while.