Note that there are some explanatory texts on larger screens.

plurals
  1. POCan't get to rebind a Repeater after firing ItemCommand (using asyncpostback via updatepanel)
    text
    copied!<p>Here's the scenario:</p> <p>I have a repeater inside an UpdatePanel called updPanel.</p> <p>Inside this repeater I have two Buttons, which fire an ItemCommand.</p> <p>In the page load I have this method:</p> <pre><code>if (!IsPostBack) { Bind(); } </code></pre> <p>Then, on Bind():</p> <pre><code>public void Bind() { rptList.DataSource = Model.GetData(Version); rptList.DataBind(); } </code></pre> <p>Then, on ItemCommand event:</p> <pre><code>public void rptList_ItemCommand(object source, RepeaterCommandEventArgs e) { //Some code to get info about the DataItems if (e.CommandName.Equals("MyCommandName1")) { //Do Stuff } else if (e.CommandName.Equals("MyCommandName2")) { //Do Other Stuff } Bind(); } </code></pre> <p>I have a button (inside the same update panel, but outside the repeater) which does nothing but Bind().</p> <p>When I click an ItemCommand, the command executes, but the screen is not updated (One of the item buttons should change its icon after clicking). If I refresh the page, or click the "Bind" button, the repeater shows the data as expected.</p> <p>Why isn't it binding after ItemCommand?</p> <p>Thanks in advance!</p> <p>EDIT: My Repeater:</p> <pre><code>&lt;asp:Repeater ID="rptList" runat="server"&gt; &lt;HeaderTemplate&gt; &lt;h3&gt; &lt;b class="rollback"&gt;Rollback&lt;/b&gt; | &lt;b class="emteste"&gt;Em Teste&lt;/b&gt; | &lt;b class="aindanaoincluido"&gt; Ainda não Incluído&lt;/b&gt; | &lt;b class="parcialmenteok"&gt;Atividade Parcialmente OK&lt;/b&gt; | &lt;b class="todosok"&gt;Atividade OK em Todas as Lojas&lt;/b&gt; | &lt;b class="publicado"&gt;Atividade Publicada&lt;/b&gt; &lt;/h3&gt; &lt;/HeaderTemplate&gt; &lt;ItemTemplate&gt; &lt;div class="item" style="display: inline-block"&gt; &lt;p style="font-size: 12px"&gt; &lt;asp:ImageButton ToolTip="Marcar como Rollback" ImageUrl="/_layouts/Extensions/Versioning/img/rollback.png" CommandName="MarkAsRollback" ID="btnItemRollback" CssClass="itembutton" runat="server" /&gt; &lt;asp:ImageButton ToolTip="Esta atividade possui código. Clique para sinalizar como apenas procedure/config" ImageUrl="/_layouts/Extensions/Versioning/img/code.png" CommandName="MarkAsProc" ID="btnItemProc" CssClass="itembutton" runat="server" /&gt; &lt;asp:Image ToolTip="Esta atividade não possui scripts de banco/zips." ImageUrl="/_layouts/Extensions/Versioning/img/noscript.png" runat="server" CssClass="itembutton" ID="btnItemScript" /&gt; &lt;asp:Label ID="labelWI" Text="" runat="server"&gt;&lt;/asp:Label&gt; &lt;span style="color: #4A82CB"&gt; &lt;%# DataBinder.Eval(Container.DataItem, "SystemAssignedTo") %&gt; - &lt;/span&gt;&lt;span style="color: Navy"&gt; &lt;%# DataBinder.Eval(Container.DataItem, "SystemTitle") %&gt; &lt;/span&gt; &lt;asp:HiddenField ID="workItemID" runat="server" /&gt; &lt;/p&gt; &lt;/div&gt; &lt;hr class="item" noshade style="color: #4CBDCB; height: 2px; background-color: #4CBDCB" /&gt; &lt;/ItemTemplate&gt; &lt;/asp:Repeater&gt; </code></pre> <p><strong>EDIT:</strong> To simplify, this is the behavior i'm getting:</p> <p>Clicking on a button outside the repeater: <strong>Icon changes. DB Updates.</strong></p> <p>Clicking on a button inside an item in the repeater: <strong>Icon doesn't change. DB Updates.</strong></p> <p>Clicking again on a button inside an item in the repeater: <strong>Icon changes. DB Updates. But now the corresponding item is wrong because I already changed the flag again</strong></p> <p>It seems to have to do with the order in which things happen.</p> <p><strong>EDIT:</strong> I forgot to mention, I tested with a full postback and everything works ok.</p>
 

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