SQLDataSource and Stored Procedure Question

D

David Hearn

I have a SQLDataSource control on one of my web forms. The stored procedure
that I am connecting to has two parameters that need to be passed in and one
that is returned. One of the parameters I am able to set at design time
because it is being set through a textbox control. The second parameter is a
combination of values from a dropdownlist and a textbox so I can't set that
at design time. How to I set the second parameter at runtime and how do I
retrieve the value of the parameter that is being passed back? I can't find
any good tutorials on how to use the SQLDataSource control so any example
code would be greatly appreciated.

Thanks in advance!
 
M

mreyeros

In order to set the second paramater you could capture the
ItemInserting event of the gridview control and the following:

SqlItemDetails is my SqlDataSource object

SqlItemDetails.InsertParameters("ItemType").DefaultValue =
CType(ItemsDetailsView.FindControl("ItemTypeDropDownList"),
DropDownList).SelectedValue

I find the parameter from my insertparameters collection and assign the
default value of this parameter to the selected value of a dropdownlist
my DetailsView control. I am also trying to figure out the third task
of retrieving a value from my stored procedure if I can figure it out I
will post to this message.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
474,262
Messages
2,571,048
Members
48,769
Latest member
Clifft

Latest Threads

Top