Answering my own question: here's 3/4 of the answer. I am still figuring out
how to pass a parameter directly from the user control to the query that
defines the ObjectDataSourc e -- if someone could answer that, I'd appreciate
it. For anyone looking for a simple example of how ObjectDataSourc e can be
parameterized, example follows.
-KF
Steps:
1) Configure your ObjectDataSourc e query to accept a parameter
2) Include a <asp:ControlPar ameter ... (nested as a SelectParameter ) that
includes a default value you wish to pass and a binding to a ControlID.
Elaborating that:
1) SELECT Contentitems.Co n_Title, ...
WHERE ( (Contentitems.S ta_StatusID <> 666 ) AND ...
(Persons.Per_Pe rsonID = @PersonID)
2)
<asp:ObjectData Source ID="odsArticles ByStaff" runat="server"
OnSelecting="Ob jectDataSource1 _Selecting"
SelectMethod="G etArticlesByUwn ewsStaff"
TypeName="Artic lesByUwnewsStaf fTableAdapters. uwnStaffArticle sTableAdapter">
<SelectParamete rs>
<asp:ControlPar ameter ControlID="Drop DownList1" DefaultValue="8 3"
Name="PersonID"
PropertyName="S electedValue" Type="Int32" />
</SelectParameter s>
</asp:ObjectDataS ource>
<asp:ObjectData Source ID="odsUwnewsSt aff" runat="server"
SelectMethod="G etNewsReleaseAu thorsDT"
TypeName="uwnew s_NewsReleaseAu thorsTableAdapt ers.DataTable1T ableAdapter">
</asp:ObjectDataS ource>
<asp:DropDownLi st ID="DropDownLis t1" runat="server"
DataSourceID="o dsUwnewsStaff" DataTextField=" Per_SurName"
DataValueField= "Per_Person ID">
<asp:ListItem Value="83">Name 1</asp:ListItem>
<asp:ListItem Value="1">Name2 </asp:ListItem>
</asp:DropDownLis t>
<asp:Button ID="Button1" runat="server" Text="submit" />
<ke*****@u.wash ington.edu> wrote in message
news:eg******** ******@TK2MSFTN GP15.phx.gbl...
Hi,
I've defined an ObjectDataSourc e and a parameterized DataSet. I would like
it if I could pass the parameter value that describes the query that
creates the DataSet as part of a user control declaration. Here's how the
parameter is described in the context of my ObjectDataSourc e:
<asp:ObjectData Source ID="ObjectDataS ource1" runat="server"
SelectMethod="G etArticlesByWho mever"
TypeName="Whate verTableAdapter s.WhateverTable Adapter">
<SelectParamete rs>
<asp:Paramete r DefaultValue="8 3" Name="PersonID" Type="Int32"
/>
</SelectParameter s>
</asp:ObjectDataS ource>
The query that's part of the DataSet has a standard @Parameter string, and
I've verfied that it is working with the DefaultValue I'm passing.
Can somone tell me how to set a differnet Parameter value using a value
passed from a User Control and/or programmaticall y?
Thanks,
-KF