View Single Post
  #28 (permalink)  
Old July 18th, 2011, 05:41 AM
priti2010 priti2010 is offline
Authorized User
Points: 63, Level: 1
Points: 63, Level: 1 Points: 63, Level: 1 Points: 63, Level: 1
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
Join Date: Jul 2011
Posts: 21
Thanks: 0
Thanked 0 Times in 0 Posts
Default how to delete gridview records

Protected Sub GridviewOdin_RowDeleting(ByVal sender As Object, ByVal e As System.Web.UI.WebControls.GridViewDeleteEventArgs) Handles GridviewOdin.RowDeleting
Try

myconnection.ConnectionString = sqlConStr
mycommand = New SqlCommand("sp_ServiceDel", myconnection)
myconnection.Open()
mycommand.CommandType = CommandType.StoredProcedure
mycommand.Parameters.Add("@Service_ID", SqlDbType.Int).Value = e.RowIndex
mycommand.ExecuteReader()
myconnection.Close()
Bindgrid()

Catch ex As Exception
Response.Write(ex.Message)
End Try

End Sub

my stored procedure
CREATE PROCEDURE [dbo].[sp_ServiceDel]
-- Add the parameters for the stored procedure here
@Service_ID int
AS
BEGIN
-- SET NOCOUNT ON added to prevent extra result sets from
-- interfering with SELECT statements.
SET NOCOUNT ON;

-- Insert statements for procedure here
DELETE tbl_Service from tbl_Service
where Service_ID = @Service_ID

select * from tbl_Service

END
i am not able to get the proper rowindex to delete the record