r k

r k

  • NA
  • 111
  • 16.9k

How to merge repeater control table cells dynamically

Aug 17 2022 6:10 PM

Hello 

I want to merge cells dynamically on conditions in ASP.net c#. Currently, I am able to hide controls but unable to merge the cells. Please help.

I want these <td colspan="5"> at runtime so all cell will be merged 

 <asp:Repeater ID="rpt" runat="server">
                <HeaderTemplate>
                    <table width="100%" border="1" style="border: solid 1px #a9a9a9;">
                        <tr style="color: #9F0000; height: 25px; font-family: Arial, Sans-Serif; font-size: 8pt; font-weight: bold; border: solid 1px Silver; background-image: url(Images/silverbg.jpg);">
                            <th align="left" valign="middle">My Repeater</th>
                            <th align="center" valign="middle" style="width: 80px">Quantity</th>
                            <th align="center" valign="middle" style="width: 60px">Book</th>
                            <th align="center" valign="middle" style="width: 80px">Rate</th>
                            <th align="center" valign="middle" style="width: 80px">Units</th>
                            <th align="center" valign="middle" style="width: 80px">Annual</th>
                            <th align="center" valign="middle" style="width: 80px">Discount</th>
                        </tr>
                </HeaderTemplate>
                <ItemTemplate>
                    <tr style="font-family: Arial, Sans-Serif; font-size: 8pt; color: #000000; padding: 3px; height: 25px; border: solid 1px #a9a9a9; border-collapse: collapse;">
                       
                        <td align="center" valign="middle" style="width: 80px;">
                            <asp:TextBox ID="txt_qty" runat="server" CssClass="frmtextbox_edit_right" Width="80px" AutoPostBack="true">

                            </asp:TextBox></td>
<td align="right" valign="middle" style="width: 80px;">
                            <asp:TextBox ID="txt_book" runat="server" CssClass="frmtextbox_edit_right" Width="80px" ReadOnly="true" ></asp:TextBox></td>
                        <td align="right" valign="middle" style="width: 80px;">
                            <asp:TextBox ID="txt_rate" runat="server" CssClass="frmtextbox_edit_right" Width="80px" AutoPostBack="true"></asp:TextBox></td>
                        <td align="center" valign="middle" style="width: 60px">
                            <asp:Label ID="lbl_units" runat="server" Text='<%# Bind("Units") %>'></asp:Label></td>
                        <td align="right" valign="middle" style="background-color: #ADD8E6; width: 80px">
                            <asp:Label ID="lbl_annual" runat="server"></asp:Label></td>
                        <td align="right" valign="middle" style="background-color: #ADD8E6; width: 80px">
                            <asp:Label ID="lbl_discount" runat="server"></asp:Label></td>
                   </ItemTemplate>
                <FooterTemplate>
                    </table>
                </FooterTemplate>
            </asp:Repeater> 


Answers (4)