Click to See Complete Forum and Search --> : Finding all DataSet members for DropDownList


Evie
06-17-2011, 08:19 AM
Hi!

I have a dropdown list from a sqlDataSource Select.

The Value is 'a_id'
The Text is 'name'
I need to find another value from the Query: 'agent_id'. How can I accomplish this?

I have the sqlDataSource as an object dragged to the page and not in the code behind.

Thanks in advance!

Ribeyed
06-18-2011, 10:16 AM
Hi,

you have to add them as SelectParameters.

http://msdn.microsoft.com/en-us/library/system.web.ui.webcontrols.sqldatasource.selectparameters.aspx

regards


Ribs

Evie
06-18-2011, 12:17 PM
Hi Rib and thanks for your response!

However, that is not what I am looking for.

I have a sqlDataSource: sqlAgentList

It calls sp_getAgentList (a stored procedure). I don't need a 'where' as I am getting a complete list.

It returns:

id
agent_id
name

I connected a DropDownList to the SqlDataSource inside a DetailsView ItemTemplate

The default view is 'Insert'.

I need all three pieces of data from that StoredProcedure.

The Value is connected to 'id'
The Text is connected to 'name'

How do I get the 'agent_id' from the resulting query?

Ribeyed
06-18-2011, 01:40 PM
Ah ok I see.

2 ways you can do that but both require that you join one column to the other in your case both ids. You can concatenate both ids in your SP and just return your 2 columns but the ids would be seperated by a special character or code behind you dropdownlist binding and concatenate it before you bind.

Then its just the case of seperating the ids later.

regards

Ribs

Evie
06-18-2011, 03:39 PM
GREAT Idea! You are awesome, thanks! I feel like a /forehead slap is in order here of course.