prema
prema

Reputation: 427

Repeater Control and Check box alignment

I am doing a asp.net web application in c#.I need an alignment as shown below: enter image description here

This alignment i want using repeater control.I used the following:

aspx page :

 <table cellspacing="0" cellpadding="0" border="0" width="80%" align="center">
        <tr>
          <td>
          </td>
      <asp:Repeater ID="rptroutebind" runat="server">
        <ItemTemplate>
            <td>                                                                                   <asp:Label ID="lblRouteName" runat="server" Text='<%# Eval("ROUTENAME") %>' Width="100"></asp:Label>
           </td>
         </ItemTemplate>
      </asp:Repeater>
      </tr>
   <asp:Repeater ID="rptbindoutlet" runat="server">
     <ItemTemplate>
         <tr>
            <td>                                                                                <asp:Label ID="lblOutName" runat="server" Text='<%# Eval("RONAME") %>' Width="100"></asp:Label>
            </td>
                </tr>
         <tr>
        <td style="height: 10px">
        </td>
        </tr>
     </ItemTemplate>
    </asp:Repeater>
  </table>

Then i am getting the following alignment without check boxes. can any one tell how to place these check boxes

EDIT : I have tried this

cs page :

protected void rptbindoutlet_ItemDataBound(object sender, RepeaterItemEventArgs e)
        {
            CheckBox chk;
            foreach (RepeaterItem item in rptbindoutlet.Items)
            {
                for (int i = 1; i <= chkno; i++)
                {
                    chk = new CheckBox();
                    chk.ID = "check" + i;
                    rptbindoutlet.Controls.Add(chk);
                }
            }
        }

i am getting check boxes but not aligning correctly.I am getting like this: enter image description here

EDIT 1 :

 protected void rptbindoutlet_ItemDataBound(object sender, RepeaterItemEventArgs e)
        {
            CheckBox chk;
            foreach (RepeaterItem item in rptbindoutlet.Items)
            {
                TableRow tr = new TableRow();
                for (int i = 1; i <= chkno; i++)
                {
                    TableCell tc = new TableCell();
                    chk = new CheckBox();
                    chk.ID = "check" + i;
                    tc.Controls.Add(chk); 
                }
                rptbindoutlet.Controls.Add(tr);
            }
        }

this gives

enter image description here

Upvotes: 0

Views: 850

Answers (1)

Gaurav Agrawal
Gaurav Agrawal

Reputation: 4431

according to you code you have added a new ItemTemplate by using c# code instead of table structure. You are using a table in the parent and at the ItemDataBound event you are just overlapping structure by a new ItemTemplate. so i advice you please generate a TableRow and TableCell and in this TableCell add new CheckBox at runtime according to your parent table structure....

Upvotes: 1

Related Questions