468,278 Members | 1,580 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 468,278 developers. It's quick & easy.

Using Stored Procedures with a Grid View

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!
Jan 11 '06 #1
1 1988
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
"mimo" <mi**@discussions.microsoft.com> wrote in message
news:87**********************************@microsof t.com...
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!

Jan 11 '06 #2

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

5 posts views Thread by Hennie | last post: by
12 posts views Thread by brwalias | last post: by
6 posts views Thread by insirawali | last post: by
reply views Thread by NPC403 | last post: by
reply views Thread by zattat | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.