开发者

Swap/disable ObjectDataSource

开发者 https://www.devze.com 2023-01-20 19:59 出处:网络
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 Cont

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.

0

精彩评论

暂无评论...
验证码 换一张
取 消