I came across this post when I was trying to dynamically add triggers to an update panel containing a gridview. I have buttons in a gridview and the trigger definition on the page does not work, since a unique identifier for each button is generated when each row is created.
The generation of such a trigger;
AsyncPostBackTrigger trigger = new AsyncPostBackTrigger(); trigger.ControlID = btn[q].UniqueID; trigger.EventName = "Click"; UpdatePanel2.Triggers.Add(trigger);
didn't work for me. The control cannot be found, however, when using the RegisterPostbackControl or RegisterAysncPostbackControl commands, it worked.
The final example is as follows:
protected void BankAccountDocumentGridView_RowDataBound(object sender, GridViewRowEventArgs e) { if (e.Row.RowType == DataControlRowType.DataRow) { LinkButton linkButton = (LinkButton)e.Row.Cells[3].FindControl("DocumentsDownloadButton"); ScriptManager.GetCurrent(Page).RegisterPostBackControl(linkButton); } }
I realized that the original posters or others that come across this post can benefit from my findings.
source share