Wednesday, March 28, 2012

Modal Popup Delete

Hey, I have a gridview with a linkbutton "delete". I made this originally with a rowcommand that deleted the item associated with that row. I am now implementing a modal pop-up to confirm deleteing the row of data. The pop-upworks fine, and appears when i click the linkbutton ( note the link button now has no "onclick" event ) the popup panel has two buttons inside it button1 and button2, 1 = confirm, 2 = cancel.

I set the CommandArguement of button1 to the ID of the item, and the CommandName to "DeleteMe". The command_row event is :

protected void GridView6_RowCommand(object sender, GridViewCommandEventArgs e)
{
if (e.CommandName == "DeleteMe")
{
SqlCommand DeleteIt = new SqlCommand("DELETE FROM Items WHERE ItemD = '" + e.CommandArgument + "'", Connection);
Connection.Open();
DeleteIt.ExecuteNonQuery();
Connection.Close();
GridView6.DataBind();
}
}

When the user clicks button1 nothing happens.. im a little bit confused as to why, can anyone help? i assumed as the ajax extender is within the gridview row it would just continue to be a row command? if im way off can someone please let me know, thanks a million John

does anyone have an ideas? sorry to be a bit pushy but its driving me insane! lol, Ive done some random google searches and in the forums and i couldnt find anything, thanks John

No comments:

Post a Comment