Click here to Skip to main content
15,892,537 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
how to write the stored procedure in gridview and how to update delete using stored procedure in gridview

[edit]Tags, and title only - Original Griff[/edit]
Posted
Updated 4-Jul-10 22:11pm
v2
Comments
Sandeep Mewara 5-Jul-10 4:14am    
Well sorry to say, you cannot write stored procedure *in* gridview. Can you elaborate more on what you are trying to do and what is the issue that you are facing?

The obvious way is to write a proper data layer and call it as needed.
 
Share this answer
 
U can't write procedure in gridview,but u can call the existing procedure created in your database in gridview events.

call procedure in events like Delete,Update
Eg: exec 'productID','productName'


Cheers
 
Share this answer
 
v2
hi,

u can call the existing procedures in gridview events. for example.

In html Page:
<asp:GridView runat=server ID=GridView5  CellPadding=3 CellSpacing=0 AutoGenerateColumns=false OnRowCommand="GridView5_RowCommand">
<Columns>
  <asp:CommandField  HeaderText="Select" ButtonType=Button  ShowEditButton=true ShowDeleteButton=true/>
 <asp:TemplateField HeaderText="Column1">
   <ItemTemplate>
    <asp:HyperLink runat=server ID=HyperLink1 Text='<%#Bind("Column1") %>' />
   </ItemTemplate>
 </asp:TemplateField>
   <asp:BoundField DataField="Column2" HeaderText="Column2" />
   <asp:BoundField DataField="Column3" HeaderText="Column3" />
</Columns>
</asp:GridView>


In code Page:
protected void GridView5_RowCommand(object sender, GridViewCommandEventArgs e)<br />
       {<br />
           int rowIndex = Convert.ToInt32(e.CommandArgument);<br />
           GridViewRow row = this.GridView5.Rows[rowIndex];<br />
           if (e.CommandName == "Edit")<br />
           {<br />
               //call stored procedure of Update<br />
           }<br />
           else if (e.CommandName == "Delete")<br />
           {<br />
               //call stored procedure of Delete<br />
           }<br />
<br />
       }



At end Hope can help u.
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900