Posts
16
Comments
100
Trackbacks
18
Repeaters, Checkboxes and UpdatePanels, Oh My!

I was working on some sample stuff that I'll be posting later and ran into a problem. I had 2 different update panels; inside one was just a div, inside the other one was a repeater. Inside the repeater I had a bunch of checkboxes, and when I checked/unchecked them, I needed the first update panel to be updated. This posed a couple of problems:

  • A checkbox doesn't have a CommandName property, and can't be used to trigger a Repeater's ItemCommand event

This I got around by declaring the event handler for the checkbox in the markup: OnCheckedChanged=”myCB_OnCheckedChanged”, and in the event handler I can cast the sender argument to a checkbox. The other problem:

  • An UpdatePanel's list of triggers can't include a control that's inside a template

Which means I can't say <atlas:ControlEventTrigger ControlID=”myCB” EventName=”myCB_OnCheckedChanged” />, since myCB doesn't actually exist at runtime. Instead, in myCB_OnCheckedChanged, I can just say: updatePanel1.Update(); and everything works fine.

Hope this helps...

posted on Monday, May 08, 2006 2:08 PM Print
Comments
Gravatar
# re: Repeaters, Checkboxes and UpdatePanels, Oh My!
Wesley Van den Eede
5/18/2006 5:24 AM
Hi Jonas,

I'm trying more or less the same but with a normal button to trigger the ItemCommandEvent.

When i surround my display area with an updatepanel i can't seem to get rid of the postbacks

this is how i declared my repeater:

<asp:Repeater ID="repMain" runat="server" OnItemCommand="repMain_ItemCommand" OnItemDataBound="repMain_ItemDataBound">
<ItemTemplate>
<tr>
<td>
<asp:Button ID="btnStatus" runat="server" Text="GO" OnClick="up1.Update();" CommandName="Display" CommandArgument="<%# Container.DataItem %>"/>
<%# Container.DataItem %>
</td>
</tr>
</ItemTemplate>
</asp:Repeater>
Gravatar
# re: Repeaters, Checkboxes and UpdatePanels, Oh My!
Jonas
5/18/2006 7:30 PM
Wesley,

Without seeing the markup for your UpdatePanel and your ScriptManager, I'm not quite sure what's not working...could you post those?
Gravatar
# re: Repeaters, Checkboxes and UpdatePanels, Oh My!
Sergio Gonzalez
12/15/2008 8:36 AM
Hola lo que debes hacer es en el codigo del itemdatabound del repeater el siguiente codigo por ej.

protected void RepeatEntidades_ItemDataBound(object sender, RepeaterItemEventArgs e)
{
if (e.Item.ItemType != ListItemType.Item) return;

CheckBox chk = (CheckBox)e.Item.FindControl("CheckBox1");
if (chk == null) return;

ScriptManager.GetCurrent(this).RegisterAsyncPostBackControl(chk);
}

ahi lo que haces es que cada vez que enlazas un item al repeater lo matriculas como control para realizar un postback asincronico. a mi me funciona perfecto, Saludos.

Post Comment

Title *
Name *
Email
Url
Comment *  
News