Alter your stored procedure as below, so that it returns some value like below:
Alter proc usp_DelTechnology
(
@TechnologyID int
)
AS
BEGIN
if(NOT EXISTS(select TechnologyID from tblTechnologySubTypes where TechnologyID = @TechnologyID) and
NOT EXISTS(select TechnologyID from tblApplicationVsTechnologies where TechnologyID = @TechnologyID) and
NOT EXISTS(select TechnologyID from tblEffortHours where TechnologyID = @TechnologyID))
BEGIN
DELETE from tblTechnologies where TechnologyID = @TechnologyID
RETURN 1
END
ELSE
BEGIN
Return 0
END
END
Now in c# code, create onClick event for image button
private void ImageButton_Click(object sender, EventArgs e)
{
using (SqlConnection con = new SqlConnection("Your database connection string here."))
{
using (SqlCommand cmd = new SqlCommand("usp_DelTechnology", con))
{
cmd.CommandType = CommandType.StoredProcedure;
cmd.Parameters.Add("@TechnologyID", SqlDbType.int).Value = GridView1.Cells[0].Text;
con.Open();
int returnValue = cmd.ExecuteNonQuery();
if (returnvalue == 0)
{
}
else
{
}
}
}
}