Below is an example of an SQLDataSource that uses a control parameter, which
takes the value from a DropDownList control.
<asp:SqlDataSou rce ID="sdsInvoices " runat="server" ConnectionStrin g="<%$
ConnectionStrin gs:someconnecti onString %>" SelectCommand=" SELECT
Accounts_Invoic eEntry_Invoices .OrderID, Accounts_Invoic eEntry_Invoices .Date,
Accounts_Invoic eEntry_Invoices .customer,
Accounts_Invoic eEntry_Invoices .customer_order ,
Accounts_Invoic eEntry_Invoices .cust_alpha,
Accounts_Invoic eEntry_Invoices .tran_code1,
Accounts_Invoic eEntry_Invoices .tran_code3,
Accounts_Invoic eEntry_Invoices .StatusID,
Accounts_Invoic eEntry_Statuses .StatusDescript ion FROM
Accounts_Invoic eEntry_Invoices INNER JOIN Accounts_Invoic eEntry_Statuses ON
Accounts_Invoic eEntry_Invoices .StatusID =
Accounts_Invoic eEntry_Statuses .StatusID WHERE
(Accounts_Invoi ceEntry_Invoice s.StatusID = @StatusID)">
<SelectParamete rs>
<asp:ControlPar ameter ControlID="ddlS tatusList" Name="StatusID"
PropertyName="S electedValue"
Type="Int32" />
</SelectParameter s>
The above bit in the <asp:ControlPar ameter > 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 ddlSelectedStat us 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 ControlParamete r, 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