G
Guest
I'm finding articles all over the place saying how to bind a dropdownlist to
an objectdatasource or sqldatasource in .NET 2.0/VS2005 but nothing that says
how to get the selected value from another datasource.
Here's the scenario.
I'm essentially loading an order for a client. There is a dropdownlist
(ddlClient) with a list of clients (populated by a sqldatasource). Each
ListItem's value is the clientID.
<asp:SqlDataSource ID="sqlClientSearch" runat="server"
ConnectionString="<%$ ConnectionStrings:MyConnectionString %>"
SelectCommand="proc_ClientLookup" SelectCommandType="StoredProcedure"
ProviderName="System.Data.SqlClient">
<SelectParameters />
</asp:SqlDataSource>
I need to load the Order object (from another datasource) and then select
the clientID on the Order in ddlClient. I tried doing this in the code
behind but when the Page_Load() runs, the binding of the ddlClient hasn't
occurred yet so it contains no ListItems (and thus
ddlClient.Items.FindByValue(clientID) doesn't work).
So I'm presuming I need to create a second data source in the aspx page that
loads the individual order record like so:
<asp:SqlDataSource ID="sqlOrderSearch" runat="server" ConnectionString="<%$
ConnectionStrings:MyConnectionString %>"
SelectCommand="proc_OrderLookup" SelectCommandType="StoredProcedure"
ProviderName="System.Data.SqlClient">
<SelectParameters> <asp:QueryStringParameter Name="OrderID"
QueryStringField="OrderID" Type="Int32" />
</asp:SqlDataSource>
But what I can't figure out is how to tell the dropdownlist ddlClient to
use the clientID field in the sqlOrderSearch datasource as the selected value.
Can someone please assist?
Thanks in advance!
an objectdatasource or sqldatasource in .NET 2.0/VS2005 but nothing that says
how to get the selected value from another datasource.
Here's the scenario.
I'm essentially loading an order for a client. There is a dropdownlist
(ddlClient) with a list of clients (populated by a sqldatasource). Each
ListItem's value is the clientID.
<asp:SqlDataSource ID="sqlClientSearch" runat="server"
ConnectionString="<%$ ConnectionStrings:MyConnectionString %>"
SelectCommand="proc_ClientLookup" SelectCommandType="StoredProcedure"
ProviderName="System.Data.SqlClient">
<SelectParameters />
</asp:SqlDataSource>
I need to load the Order object (from another datasource) and then select
the clientID on the Order in ddlClient. I tried doing this in the code
behind but when the Page_Load() runs, the binding of the ddlClient hasn't
occurred yet so it contains no ListItems (and thus
ddlClient.Items.FindByValue(clientID) doesn't work).
So I'm presuming I need to create a second data source in the aspx page that
loads the individual order record like so:
<asp:SqlDataSource ID="sqlOrderSearch" runat="server" ConnectionString="<%$
ConnectionStrings:MyConnectionString %>"
SelectCommand="proc_OrderLookup" SelectCommandType="StoredProcedure"
ProviderName="System.Data.SqlClient">
<SelectParameters> <asp:QueryStringParameter Name="OrderID"
QueryStringField="OrderID" Type="Int32" />
</asp:SqlDataSource>
But what I can't figure out is how to tell the dropdownlist ddlClient to
use the clientID field in the sqlOrderSearch datasource as the selected value.
Can someone please assist?
Thanks in advance!