I Have a gridview which has a row that contains LinkButtons that were added dynamically. when these LinkButtons are clicked I need to show a confirmation dialog. I tried to work as suggested in this post: JQuery DIalog and ASP.NET Repeater but it doesn't work, the postBackReference doesn't contain the right ID (it ignores the placeholder) this is my code:
GridView1_RowCreated(Object sender, GridViewRowEventArgs e)
{
//some code here
LinkButton lb = new LinkButton();
lb.Text = "something";
lb.ID = "someId";
string postBackReference = ClientScript.GetPostBackEventReference(lb, string.Empty);
lb.OnClientClick = "javascript: showConf(function(){"+ postBackReference +"});return false;";
TableCell cell = new TableCell();
cell.Controls.Add(lb);
e.Row.Cells.Add(cell);
}
Does anyone has an idea ?
OnRowDataBoundorOnRowCreatedI would add an extra parameter to theshowConfirmationfunction with your own id so that you don't have to parse the server-side id at all to know on which record you are operating. I put some details on the comments section of my answer.