473,385 Members | 1,337 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,385 software developers and data experts.

Databound dropdownlist: selectedValue from a second datasource?

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!
Dec 19 '05 #1
0 1088

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

1
by: jimb | last post by:
I can get the dropdownlist into the datagrid, and I can populate it, but I can't read it. Anybody have a working example of a dropdownlist in an editable grid? Thanks. -- .....
0
by: Tand35006 | last post by:
Hi, I hope some one can help with this. I have a basic webform with 2 DropDownLists and a single DataGrid. What I am trying to do is populate the first DDList from a dataset on Form_Load. I then...
6
by: dbuchanan | last post by:
VS2005 I've been reading all the help I can on the topic (MSDN, other) but I can't make sense of this. Desired behavior; The user is to choose from the displayed list of the databound combobox...
9
by: Jakob Lithner | last post by:
1) I have a DataGridView with edit capability. But in some columns I want to limit the input with a DropDownList. There is no inbuilt column for DropDownLists so I intended to add one myself. I...
11
by: Santosh | last post by:
Dear all , i am writting following code. if(Page.IsPostBack==false) { try { BindSectionDropDownlist();
0
by: Mark Micallef | last post by:
Hi, I'm having a problem using a databound dropdownlist inside a reorderlist ajax control. Here's a snippet of the code I'm using: <InsertItemTemplate> <div class="insertArea">...
1
by: Mark Micallef | last post by:
Hi, this question relates to a control in the Ajax toolkit for asp.net 2. I'm having a problem using a databound dropdownlist inside a reorderlist ajax control. Here's a snippet of the code I'm...
2
by: sree reddy | last post by:
..cs using System; using System.Data; using System.Configuration; using System.Collections; using System.Web; using System.Web.Security; using System.Web.UI; using System.Web.UI.WebControls;
5
by: Cirene | last post by:
I seem to remember seeing a solution where a databound dropdownlist (used as a FILTER for a gridview) had the 1st item as "ALL ITEMS". It used a query with a UNION. But I can't find the example....
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.