Step 1 : Add In Gridview ASPX Page
<asp:TemplateField>
<ItemTemplate>
<asp:LinkButton ID="LinkButton1" runat="server"
CommandArgument='<%# Eval("biInvitationId") %>'
CommandName="dele">Delete</asp:LinkButton>
</ItemTemplate>
</asp:TemplateField>
protected void GridView1_RowCommand(object sender, GridViewCommandEventArgs e)
{
if (e.CommandName == "dele")
{
string biInvitationId = e.CommandArgument.ToString();
strResult = DeleteCourseYearDetails(entCourse);
}
}
public string DeleteCourseYearDetails(object Id)
{
Ent_Course entCourse = (Ent_Course)Id;
using (SqlCommand cmd = DBhelper.Instance.GetCommand("SP_DELETE_COURSEYEAR", CommandType.StoredProcedure))
{
cmd.Parameters.AddWithValue("@COURSEID", entCourse.CourseId);
cmd.Parameters.AddWithValue("@RESULT", "");
cmd.Parameters["@Result"].Direction = ParameterDirection.Output;
cmd.ExecuteNonQuery();
Result = cmd.Parameters["@Result"].Value.ToString();
DBhelper.Instance.CloseConnection(cmd);
}
return Result;
}
Step 2 : Stored Procedure
CREATE PROCEDURE [dbo].[SP_DELETE_COURSEYEAR]
@COURSEID INT,
@RESULT CHAR(1) OUTPUT
AS
BEGIN
--DECLARE @COUNT INT
--SET @RESULT='N'
--SET @COUNT=(SELECT COUNT(*) FROM CourseYear WHERE Id=@COURSEID)
--IF(@COUNT > 0)
BEGIN
DELETE FROM CourseYear WHERE Id=@COURSEID
SET @RESULT='Y'
END
END
No comments:
Post a Comment