Bineesh  Viswanath

Bineesh Viswanath

  • NA
  • 1k
  • 777.7k

ASP.NET GridView RowDeleting Event

Aug 20 2013 12:27 AM
Sir, I am in the program of asp.net gridView RowDeleteEvent .

I want your help in this event. I am showing  SQL Sp to Default.aspx.cs.

1)SQL SP

ALTER PROCEDURE  movieDelete
@movieId int
AS
    delete from tbl_Movie where movieId=@movieId
    RETURN

2)Default.aspx

<asp:TemplateField HeaderText="Delete">
                                <ItemTemplate>
                                    <asp:LinkButton ID="lnkDelete" runat="server" CommandArgument='<%#Eval("movieid") %>'
                                        CommandName="Delete">Delete</asp:LinkButton>
                                </ItemTemplate>

3) Default.aspx.cs


 protected void dgvMovie_RowDeleting(object sender, GridViewDeleteEventArgs e)
        {
           
            int inId = Convert.ToInt32(dgvMovie.DataKeys[e.RowIndex].Value.ToString());
            if (sqlCon.State == ConnectionState.Closed)
            {
                sqlCon.Open();
            }
            SqlCommand c = new SqlCommand("moviedelete", sqlCon);
            c.CommandType = CommandType.StoredProcedure;
            c.Parameters.AddWithValue("@movieId", inId);
            c.ExecuteNonQuery();
            GridFill();
        }
I getting either error nor output, just showing viewstate1.

Answers (4)