Using Stored Procedures with a Grid View

G

Guest

Hi,

I'm trying to use Stored Procedures with a Grid View and everytime I try the
update and the delete stored procedures fail. By the way I am doing this
through the wizard.

Is there a sample somewhere on how to do this? When I type in the
statements directly it works, but I really need to be able to call stored
procedures. And the stored procedures work fine in query analyzer.

Thanks!
 
S

S. Justin Gengo

Mimo,

I don't have a full example for you, but I've successfully used sprocs with
my gridview and formview controls in a current project.

I found that for the delete and update sprocs I had to specify the primary
key in the datagrid header like this:

<asp:GridView ID="GridView1" runat="server" AllowPaging="True"
AllowSorting="True"
AutoGenerateColumns="False" CellPadding="4" DataSourceID="SqlDataSource1"
ForeColor="#333333"
GridLines="None" PageSize="25" DataKeyNames="pk_InventoryId">

Note the "DataKeyNames" entry.

Also for my update command, which is in a formview control, I had some drop
down lists that I needed to retrieve values from. I did that inside of the
ItemUpdating event (which fires just before the update) like this:

'---Set drop down parameters
e.NewValues.Item("CountryId") =
CType(FormView1.FindControl("CountrysDropDownList"),
DropDownList).SelectedValue


--
Sincerely,

S. Justin Gengo, MCP
Web Developer / Programmer

www.aboutfortunate.com

"Out of chaos comes order."
Nietzsche
 

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
473,756
Messages
2,569,533
Members
45,007
Latest member
OrderFitnessKetoCapsules

Latest Threads

Top