Here's the scenario:
I have a repeater inside an UpdatePanel called updPanel.
Inside this repeater I have two Buttons, which fire an ItemCommand.
In the page load I have this method:
if (!IsPostBack)
{
Bind();
}
Then, on Bind():
public void Bind()
{
rptList.DataSource = Model.GetData(Version);
rptList.DataBind();
}
Then, on ItemCommand event:
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();
}
I have a button (inside the same update panel, but outside the repeater) which does nothing but Bind().
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.
Why isn't it binding after ItemCommand?
Thanks in advance!
EDIT: My Repeater:
<asp:Repeater ID="rptList" runat="server">
<HeaderTemplate>
<h3>
<b class="rollback">Rollback</b> | <b class="emteste">Em Teste</b> | <b class="aindanaoincluido">
Ainda não Incluído</b> | <b class="parcialmenteok">Atividade Parcialmente OK</b>
| <b class="todosok">Atividade OK em Todas as Lojas</b> | <b class="publicado">Atividade
Publicada</b>
</h3>
</HeaderTemplate>
<ItemTemplate>
<div class="item" style="display: inline-block">
<p style="font-size: 12px">
<asp:ImageButton ToolTip="Marcar como Rollback" ImageUrl="/_layouts/Extensions/Versioning/img/rollback.png"
CommandName="MarkAsRollback" ID="btnItemRollback" CssClass="itembutton" runat="server" />
<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" />
<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" />
<asp:Label ID="labelWI" Text="" runat="server"></asp:Label>
<span style="color: #4A82CB">
<%# DataBinder.Eval(Container.DataItem, "SystemAssignedTo") %>
- </span><span style="color: Navy">
<%# DataBinder.Eval(Container.DataItem, "SystemTitle") %>
</span>
<asp:HiddenField ID="workItemID" runat="server" />
</p>
</div>
<hr class="item" noshade style="color: #4CBDCB; height: 2px; background-color: #4CBDCB" />
</ItemTemplate>
</asp:Repeater>
EDIT: To simplify, this is the behavior i'm getting:
Clicking on a button outside the repeater: Icon changes. DB Updates.
Clicking on a button inside an item in the repeater: Icon doesn't change. DB Updates.
Clicking again on a button inside an item in the repeater: Icon changes. DB Updates. But now the corresponding item is wrong because I already changed the flag again
It seems to have to do with the order in which things happen.
EDIT: I forgot to mention, I tested with a full postback and everything works ok.