How to use an UpdatePanel inside a Reapeater ItemTemplate with a HTML Table

Posted by vanslly on Stack Overflow See other posts from Stack Overflow or by vanslly
Published on 2010-04-23T00:34:46Z Indexed on 2010/04/23 0:43 UTC
Read the original article Hit count: 329

Filed under:

I want to allow the user to edit by data by row, so only need content updated by row. I managed to achieve this by using a Repeater with a UpdatePanel in the ItemTemplate.

Using a div

<asp:ScriptManager ID="ctlScriptManager" runat="server" />
<asp:Repeater ID="ctlMyRepeater" runat="server">
    <ItemTemplate>
        <div>
            <asp:UpdatePanel ID="ctlUpdatePanel" runat="server">
                <ContentTemplate>
                    <asp:Label ID="lblName" runat="server"
                        Text='<%# Eval("Name") %>' />
                    <asp:LinkButton ID="btnRename" runat="server"
                        CommandArgument='<%# Eval("ID") %>'
                        CommandName="Rename">Rename...</asp:LinkButton>
                </ContentTemplate>
                <Triggers>
                    <asp:AsyncPostBackTrigger ControlID="btnRename" 
                        EventName="Click" />
                </Triggers>
            </asp:UpdatePanel>
        </div>
    </ItemTemplate>
</asp:Repeater>

But, I want to use a table to ensure structure and spacing and CSS styling wasn't doing it for me, but when I use a table everything goes whacky.

Using a Table

<asp:ScriptManager ID="ctlScriptManager" runat="server" />
<table>
    <asp:Repeater ID="ctlMyRepeater" runat="server">
        <ItemTemplate>
            <asp:UpdatePanel ID="ctlUpdatePanel" runat="server">
                <ContentTemplate>
                    <tr>
                        <td>
                            <asp:Label ID="lblName" runat="server"
                                Text='<%# Eval("Name") %>' />
                        </td>
                        <td>
                            <asp:LinkButton ID="btnRename" runat="server"
                                CommandArgument='<%# Eval("ID") %>'
                                CommandName="Rename">Rename...</asp:LinkButton>
                        </td>
                    </tr>
                </ContentTemplate>
                <Triggers>
                    <asp:AsyncPostBackTrigger ControlID="btnRename"
                        EventName="Click" />
                </Triggers>
            </asp:UpdatePanel>
        </ItemTemplate>
    </asp:Repeater>
</table>

What's the best way to solve this problem? I prefer using a table, because I really want to enfore structure without reliance on CSS.

Thanks in advance.

© Stack Overflow or respective owner

Related posts about asp.net-ajax