Custom DataSource Extender
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:DataV开发者_如何学编程iewSource>
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
.
The code I was stuck at:
DataView dv = dsFoo.Select(DataSourceSelectArguments.Empty) as DataView;
DataTable dt = dv.ToTable()
The second line is likely unnecessary since the original goal was to turn a DataSource
into a DataView
.
Of course, looking up this stuff tells me that SqlDataSource
already has FilterExpression
...
精彩评论