自定义数据源扩展器
我梦想创建一个像这样工作的控件:
<asp:SqlDataSource
id="dsFoo"
runat="server"
ConnectionString="<%$ ConnectionStrings:conn %>"
SelectCommandType="StoredProcedure"
SelectCommand="cmd_foo">
</asp:SqlDataSource>
<Custom:DataViewSource
id="dvFoo"
runat="server"
rowfilter="colid > 10"
datasourceid="dsFoo">
</Custom:DataViewSource>
我可以通过执行 cmd_foo
在后面的代码中完成同样的事情,将结果加载到 DataTable
中,然后加载它们到带有 RowFilter
的 DataView
中。目标是为一个 DataSource
提供多个 DataView
,并使用我希望应用于 DataSource
的选择部分的任何特殊过滤器。我可以想象将其扩展为更强大。
目前,我的主要问题是不确定在哪里获取 DataSource 的输出数据,以便我可以将其粘贴到 DataTable 中。
I dream of creating a control which works something like this:
<asp:SqlDataSource
id="dsFoo"
runat="server"
ConnectionString="<%$ ConnectionStrings:conn %>"
SelectCommandType="StoredProcedure"
SelectCommand="cmd_foo">
</asp:SqlDataSource>
<Custom:DataViewSource
id="dvFoo"
runat="server"
rowfilter="colid > 10"
datasourceid="dsFoo">
</Custom:DataViewSource>
I can accomplish the same thing in the code behind by executing cmd_foo
, loading the results into a DataTable
, then loading them into a DataView
with a RowFilter
. The goal would be to have multiple DataView
s for one DataSource
with whatever special filters I wish to apply to the select portion of the DataSource
. I could imagine extending this to be more powerful.
I tried peaking at this and this but am a bit confused on a few points.
Currently, my main issue is being unsure where to grab the output data of the DataSource
so I can stick it into a DataTable
.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
我陷入困境的代码:
第二行可能是不必要的,因为最初的目标是将
DataSource
转换为DataView
。当然,查找这些东西告诉我
SqlDataSource
已经有FilterExpression
...The code I was stuck at:
The second line is likely unnecessary since the original goal was to turn a
DataSource
into aDataView
.Of course, looking up this stuff tells me that
SqlDataSource
already hasFilterExpression
...