Resolve a Late-Binding Web Forms MVP and Telerik Control Issue

When working with Web Forms MVP framework and Teleriks RadGrid everything runs great up until the point you turn on filtering. Then bam! You’re hit with this beautiful exception … Load(Sarcasm) …

At first we were confused by the exception being that we didn’t have any RadComboBoxes on the page but as it turns out, RadGrid loads RadComboBoxes when you turn on filtering. Now the problem lies with MVP databinding OnPreRender causing the RadComboBox to register a script too late in the page lifecycle.

To fix this issue, you can just set AutoDataBind to false. Oddly enough, that didn’t work neither. We set it in OnLoad, then OnInit and nothing. We didn’t have PreInit available as this was a User Control (.ascx) so we added a constructor and set it in there and viola! It worked.

[[code lang=”csharp[lines]”]]czoyMzU6XCJbUHJlc2VudGVyQmluZGluZyh0eXBlb2YoU3RvcnlMaXN0UHJlc2VudGVyKSldDQpwdWJsaWMgcGFydGlhbCBjbGFzcyB7WyYqJl19U3RvcnlMaXN0Q29udHJvbCA6IFdlYkZvcm1zTXZwLldlYi5NdnBVc2VyQ29udHJvbDxTdG9yeUxpc3RNb2RlbD4sIElTdG9yeUxpc3tbJiomXX10Vmlldw0Kew0KICAgcHVibGljIFN0b3J5TGlzdENvbnRyb2woKQ0KICAgew0KICAgICAgQXV0b0RhdGFCaW5kID0gZmFsc2U7DQoge1smKiZdfSAgfQ0KICAgLi4uDQp9XCI7e1smKiZdfQ==[[/code]]

Share on FacebookTweet about this on TwitterShare on Google+Share on LinkedInShare on Reddit