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 ?
So here is a solution that worked for me:
Basically I worked according to the solution in this post:
JQuery DIalog and ASP.NET Repeater
The only difference was that I had to use the RowCreated Event for adding my dynamic LinkButtons and RowDataBound Event for registering my client function (otherwise the original __doPostBack wouldn’t get the ID param correctly (as if it ignores the fact that it is in a place holder)).
So my code behind looks like this now:
and:
client function- showConf and markup stay as they were.