Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>To register a control as a trigger for a postback, use ScriptManager's RegisterPostBackControl Method.</p> <pre><code> If editLink IsNot Nothing Then ScriptManager.GetCurrent(this.Page).RegisterPostBackControl(editLink ) End If </code></pre> <p>This methods works too for controls dynamically added within other controls. I had the same problem with my GridView. I've registered linkButton and imageButton of a TemplatedField row. </p> <p>I use RowCreated Gridview's handler instead of RowDataBound handler : RowCreated is focused on parsing Gridview row's definition and creating the Gridview row's control structure, RowDataBound is focused on bind data to the row's controls created in the RowCreated. Also RowCreated is invoked automatically in both init and postback case, but RowDataBound is only invoke when the DataBind is called. Code </p> <pre><code>&lt;asp:GridView ID="ContactsGridView" runat="server" AutoGenerateColumns="False" DataSourceID="ContactsContainerDataSource" EnableViewState="false" DataKeyNames="CompanyID,ContactId" AllowSorting="True" AllowPaging="true" OnRowCreated="ContactsGridView_RowCreated" PageSize="10" CssClass="GridSimple" OnRowCommand="ContactsGridView_RowCommand"&gt; &lt;Columns&gt; &lt;asp:TemplateField HeaderStyle-CssClass="large" HeaderText="Contact" SortExpression="ContactNom"&gt; &lt;ItemTemplate&gt; &lt;asp:ImageButton ID="PreviewImageButton" runat="server" ImageUrl="../images/picto_pdf.gif" CommandName="PreviewContact" CommandArgument=&lt;%#Eval("ContactCode") %&gt; BorderWidth="0" ToolTip="View Pdf Document" /&gt; &lt;asp:LinkButton ID="ContactNamePreviewLinkButton" runat="server" CommandName="Select" CommandArgument='&lt;%#Eval("ContactCode") %&gt;'&gt;&lt;%#Eval("ContactName")%&gt;&lt;/asp:LinkButton&gt; &lt;/ItemTemplate&gt; &lt;/asp:TemplateField&gt; &lt;/Columns&gt; &lt;/asp:GridView&gt; protected void ContactsGridView_RowCreated(object sender, GridViewRowEventArgs e) { if (e.Row.RowType == DataControlRowType.DataRow) { //Register download buttons as PostBack controls (instead of AsyncPostback because of their updatepanel container)) ImageButton ib = (ImageButton)e.Row.FindControl("PreviewImageButton"); if (ib != null) ScriptManager.GetCurrent(this.Page).RegisterPostBackControl(ib); LinkButton lb = (LinkButton)e.Row.FindControl("ContactNamePreviewLinkButton"); if (lb != null) ScriptManager.GetCurrent(this.Page).RegisterPostBackControl(lb); } } protected void ContactsGridView_RowCommand(object sender, GridViewCommandEventArgs e) { if (e.CommandName == "PreviewContact") { _presenter.OnPreviewContactClicked((string)e.CommandArgument); } } </code></pre>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. VO
      singulars
      1. This table or related slice is empty.
    2. VO
      singulars
      1. This table or related slice is empty.
    3. VO
      singulars
      1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload