tags:

views:

71

answers:

1

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 enforce structure without reliance on CSS.

Thanks in advance.

A: 

Three thoughts that may help....

  1. Move the update panel to outside the repeater control instead of in the template...
  2. Use the ListView Control but again moving the panel outside of the template...
  3. Perhaps showing us the CSS you have tried on the div's and what you want so we can help will get you working with your first sample using divs again...
klabranche
Moving the UpdatePanel outside of the Repeater would result in a less effective UI for me. Imagine the data represented by the Repeater as taking 5 seconds to obtain, you wont want to waste 5 seconds each time only one item is removed/renamed.Using a Div would solve the problem, but I want my columns to resize based on the cell contents. Eg, if the name is long the column grows, if the description is large then its column grows. This is not ideal for CSS if I'm not wrong and a table solves this UI concern for a structured layout. So... going the div route isn't ideal.
vanslly
Have you tried adding a style to the div of "display: table-cell;"?
klabranche
I did and I could not seem to maintain the structural integrity of the table metaphor when cells need to grow to accomodate data that needs to be wrapped.
vanslly
klabranche

related questions