I haven't done this before and need some guidance.
I need to collect the value from a hidden field on a GridView and pass that value to an SQL Server stored procedure in order to create a new row in the gridview and assign the foreign key value to the appropriate field in the underlying table.
Unfortunately I'm not conversant with C# so VB.Net examples etc. please.
I'm not really sure how to have the stored procedure locate and use the value either.
JayDubbya
Member
61 Points
57 Posts
Pass value from GridView field to stored procedure.
May 02, 2012 11:51 PM|LINK
Hi all.
I haven't done this before and need some guidance.
I need to collect the value from a hidden field on a GridView and pass that value to an SQL Server stored procedure in order to create a new row in the gridview and assign the foreign key value to the appropriate field in the underlying table.
Unfortunately I'm not conversant with C# so VB.Net examples etc. please.
I'm not really sure how to have the stored procedure locate and use the value either.
basheerkal
Star
10672 Points
2426 Posts
Re: Pass value from GridView field to stored procedure.
May 03, 2012 03:03 AM|LINK
Add that field as the DataKeyNames of the GridView and retrieve it in RowDataBound event.
Check his link for some clues.
http://stackoverflow.com/questions/3554870/pass-value-from-gridview-to-stored-procedure
(Talk less..Work more)
ZeeshanAnsar...
Participant
878 Points
264 Posts
Re: Pass value from GridView field to stored procedure.
May 03, 2012 03:39 AM|LINK
the value which your binding to hidden field inside fieldtemplate
that can be retrieved in rowdatabound event as
HiddenField hdnFD= (HiddenField)e.Row.FindControl("hdnField1"); hdnFD.Value; // pass this value to your sp.I hope this helps
Please 'Mark as Answer' if this post helps you.
santosh.pras...
Member
3 Points
15 Posts
Re: Pass value from GridView field to stored procedure.
May 03, 2012 05:06 AM|LINK
I have the same scenario . And the below code help me a lot :-).