Using Stored Procedures with a Grid View

  • Thread starter Thread starter Guest
  • Start date Start date
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!
 
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
 
Back
Top