On grid RowDataBound based on some condition i've added imagebutton dynamically. parallelly i want to add event for this button click. here is my code snippet
Code
protected void GV3_RowDataBound(object sender, GridViewRowEventArgs e)Code
{Code
if (e.Row.RowType == DataControlRowType.DataRow)Code
{Code
TableCell cell = new TableCell();Code
ImageButton bttn = new ImageButton();Code
bttn.CommandName = "Delete";Code
bttn.ImageUrl = "delete.png";Code
bttn.ToolTip = "Click to delete this record";Code
bttn.CommandArgument = e.Row.Cells[0].Text;Code
cell.Controls.Add(bttn);Code
e.Row.Cells.Add(cell);Code
bttn.OnClientClick = "return confirm('Are you sure you to delete " + e.Row.Cells[0].Text + "?');";Code
}Code
}Code
bttn.Click += new ImageClickEventHandler(b_Click);Code
private void b_Click(object sender, EventArgs e)Code
{ //delete recordCode
}

Answers
Know the answer? Post it. Somebody with the same question will find it here.