开发者

Remove DataSourceID with code?

开发者 https://www.devze.com 2023-03-06 11:11 出处:网络
I have a DataList which is bound to a SqlDataSource, Ive got a LINQ query which the users can use to narrow down the data, I\'m making the DataSource = the LINQ on the click event of a button.

I have a DataList which is bound to a SqlDataSource, Ive got a LINQ query which the users can use to narrow down the data, I'm making the DataSource = the LINQ on the click event of a button.

I get an error as the list has a DataSourceID and now I'm giving it a DataSource.

Think this would work if i removed the datasourceid first with code before binding to 开发者_高级运维the new LINQ? If so, any hints on how to do this?

Thanks.


BaseDataBoundControl, BaseDataList, etc has 2 options how data can be bound to:

  • DataSource (like LINQ result)
  • DataSourceId (like SqlDataSource)

Use one of them, or null first before assigning second.

0

精彩评论

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