Note that there are some explanatory texts on larger screens.

plurals
  1. POUpdatePanel, Repeater, DataBinding Problem
    primarykey
    data
    text
    <p>In a user control, I've got a Repeater inside of an UpdatePanel (which id displayed inside of a ModalPopupExtender. The Repeater is databound using an array list of MyDTO objects. There are two buttons for each Item in the list. Upon binding the ImageURL and CommandArgument are set.</p> <p>This code works fine the first time around but the CommandArgument is wrong thereafter. It seems like the display is updated correctly but the DTO isn't and the CommandArgument sent is the one that has just been removed.</p> <p>Can anybody spot any problems with the code?</p> <p><strong>Edit : I've just added a CollapsiblePanelExtender to the code. When I now delete an item and expand the panel, the item that was previously deleted (and gone from the display) has come back. It seems that the Repeater hasn't been rebuilt correctly under the bonnet.</strong></p> <p>ASCX</p> <pre><code>&lt;asp:UpdatePanel ID="ViewDataDetail" runat="server" ChildrenAsTriggers="true"&gt; &lt;Triggers&gt; &lt;asp:PostBackTrigger ControlID="ViewDataCloseButton" /&gt; &lt;asp:AsyncPostBackTrigger ControlID="DataRepeater" /&gt; &lt;/Triggers&gt; &lt;ContentTemplate&gt; &lt;table width="100%" id="DataResults"&gt; &lt;asp:Repeater ID="DataRepeater" runat="server" OnItemCommand="DataRepeater_ItemCommand" OnItemDataBound="DataRepeater_ItemDataBound"&gt; &lt;HeaderTemplate&gt; &lt;tr&gt; &lt;th&gt;&lt;b&gt;Name&lt;/b&gt;&lt;/th&gt; &lt;th&gt;&lt;b&gt;&amp;nbsp;&lt;/b&gt;&lt;/th&gt; &lt;/tr&gt; &lt;/HeaderTemplate&gt; &lt;ItemTemplate&gt; &lt;tr&gt; &lt;td&gt; &lt;b&gt;&lt;%#((MyDTO)Container.DataItem).Name%&gt;&lt;/b&gt; &lt;/td&gt; &lt;td&gt; &lt;asp:ImageButton CausesValidation="false" ID="DeleteData" CommandName="Delete" runat="server" /&gt; &lt;asp:ImageButton CausesValidation="false" ID="RunData" CommandName="Run" runat="server" /&gt; &lt;/td&gt; &lt;/tr&gt; &lt;tr&gt; &lt;td colspan="2"&gt; &lt;table&gt; &lt;tr&gt; &lt;td&gt;Description : &lt;/td&gt; &lt;td&gt;&lt;%#((MyDTO)Container.DataItem).Description%&gt;&lt;/td&gt; &lt;/tr&gt; &lt;tr&gt; &lt;td&gt;Search Text : &lt;/td&gt; &lt;td&gt;&lt;%#((MyDTO)Container.DataItem).Text%&gt;&lt;/td&gt; &lt;/tr&gt; &lt;/table&gt; &lt;/td&gt; &lt;/tr&gt; &lt;/ItemTemplate&gt; &lt;/asp:Repeater&gt; &lt;/table&gt; &lt;/ContentTemplate&gt; &lt;/asp:UpdatePanel&gt; </code></pre> <p>Code-Behind</p> <pre><code> public DeleteData DeleteDataDelegate; public RetrieveData PopulateDataDelegate; public delegate ArrayList RetrieveData(); public delegate void DeleteData(String sData); protected void Page_Load(object sender, EventArgs e) { //load the initial data.. if (!Page.IsPostBack) { if (PopulateDataDelegate != null) { this.DataRepeater.DataSource = this.PopulateDataDelegate(); this.DataRepeater.DataBind(); } } } protected void DataRepeater_ItemCommand(object source, RepeaterCommandEventArgs e) { if (e.CommandName == "Delete") { if (DeleteDataDelegate != null) { DeleteDataDelegate((String)e.CommandArgument); BindDataToRepeater(); } } else if (e.CommandName == "Run") { String sRunning = (String)e.CommandArgument; this.ViewDataModalPopupExtender.Hide(); } } protected void DataRepeater_ItemDataBound(object source, RepeaterItemEventArgs e) { RepeaterItem item = e.Item; if (item != null &amp;&amp; item.DataItem != null) { MyDTO oQuery = (MyDTO)item.DataItem; ImageButton oDeleteControl = (ImageButton) item.FindControl("DeleteData"); ImageButton oRunControl = (ImageButton)item.FindControl("RunData"); if (oDeleteControl != null &amp;&amp; oRunControl !=null) { oRunControl.ImageUrl = "button_expand.gif"; oRunControl.CommandArgument = "MyID"; if (oQuery !=null) { //do something } oDeleteControl.ImageUrl = "btn_remove.gif"; oDeleteControl.CommandArgument = "MyID"; } } } public void BindDataToRepeater() { this.DataRepeater.DataSource = this.PopulateDataDelegate(); this.DataRepeater.DataBind(); } public void ShowModal(object sender, EventArgs e) { BindDataToRepeater(); this.ViewDataModalPopupExtender.Show(); } </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.
 

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