Jonas Bush

Blog.blog.blog.blog
posts - 16, comments - 161, trackbacks - 17

My Links

News

Archives

Post Categories

Image Galleries

General

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...

  • Share This Post:
  • Share on Twitter
  • Share on Facebook
  • Share on Technorati

Print | posted on Monday, May 08, 2006 2:08 PM | Filed Under [ Atlas ASP.Net ]

Feedback

Gravatar

# re: Repeaters, Checkboxes and UpdatePanels, Oh My!

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>
5/18/2006 5:24 AM | Wesley Van den Eede
Gravatar

# re: Repeaters, Checkboxes and UpdatePanels, Oh My!

Wesley,

Without seeing the markup for your UpdatePanel and your ScriptManager, I'm not quite sure what's not working...could you post those?
5/18/2006 7:30 PM | Jonas
Gravatar

# re: Repeaters, Checkboxes and UpdatePanels, Oh My!

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.
12/15/2008 8:36 AM | Sergio Gonzalez
Post A Comment
Title:
Name:
Email:
Website:
Comment:
Verification:
 
 

Powered by: