Swap/disable ObjectDataSource
I have a GridView which selectively binds to one of two ObjectDataSources. I make the switch in the Page_Load by setting GridView.DataSourceID. One of the data sources has parameters which refer to ControlIDs which don't always exist. Even if it's not set as a DataSource开发者_Go百科ID, the data source tries to get the values for the ControlIDs, throwing an exception.
Is there any way to disable the data source I don't need? I tried Dispose() and setting to null, but it still throws the error. Setting the param values OnSelecting would complicate things so I would like to avoid that if possible.
Instead of disposing, I did SelectParameters.Clear()
and that took care of the problem.
精彩评论