Below is an example of an SQLDataSource that uses a control parameter, which
takes the value from a DropDownList control.
<asp:SqlDataSource ID="sdsInvoices" runat="server" ConnectionString="<%$
ConnectionStrings:someconnectionString %>" SelectCommand="SELECT
Accounts_InvoiceEntry_Invoices.OrderID, Accounts_InvoiceEntry_Invoices.Date,
Accounts_InvoiceEntry_Invoices.customer,
Accounts_InvoiceEntry_Invoices.customer_order,
Accounts_InvoiceEntry_Invoices.cust_alpha,
Accounts_InvoiceEntry_Invoices.tran_code1,
Accounts_InvoiceEntry_Invoices.tran_code3,
Accounts_InvoiceEntry_Invoices.StatusID,
Accounts_InvoiceEntry_Statuses.StatusDescription FROM
Accounts_InvoiceEntry_Invoices INNER JOIN Accounts_InvoiceEntry_Statuses ON
Accounts_InvoiceEntry_Invoices.StatusID =
Accounts_InvoiceEntry_Statuses.StatusID WHERE
(Accounts_InvoiceEntry_Invoices.StatusID = @StatusID)">
<SelectParameters>
<asp:ControlParameter ControlID="ddlStatusList" Name="StatusID"
PropertyName="SelectedValue"
Type="Int32" />
</SelectParameters>
The above bit in the <asp:ControlParameter > tags is the key. the Mane
property matches a parameter within your SQLQuery or stored procedure, in the
above example this is @StatusID. The ControlID property is set to the ID of
the control from which to take the value of the parameter, in the case a
DropDownList control called ddlSelectStatus. This can be any ASP.net
control. The PropertyName property is the property of the control poited to
by ControlID, from which you want to take the value for the parameter. In
this case it takes the SelectedValue from the ddlSelectedStatus control.
In your case you would just set up the DataSource control to return the
values you needed, with a "WHERE ForeignKeyID = @MyParam" type where clause.
Then set up MyParam as a ControlParameter, as in the example above, but set
the controlID to the ID of your GridView and set the PropertyName to
SelectedValue. The just bind this datasource to the FormView using the
DataSourceID property and it will work.
"mosscliffe" wrote:
If that is the answer fine, but I am afraid you are talking to someone
very unskilled in this and I do not know what a Control Parameter is.
I just need a simple example - please.
I can get it all to work by doing the code myself, but I thought I
would try using all these wonderful controls, but it seems a very steep
learning curve.
Tim