Checkboxes in placeholder

Results 1 to 2 of 2

Thread: Checkboxes in placeholder

  1. #1
    Join Date
    Dec 1969

    Default Checkboxes in placeholder

    Hi i am doing project in<BR>I am displaying checkboxes dynamically in placeholder.I can display the checboxes but its displaying without proper aligjnment.How to display cjecboxes with proper alignments.I just place my placeholder in tbale tag.Pl advid me.<BR>code is like below<BR><BR><BR>&#060;table border="1"&#062;<BR> &#060;tr&#062;<BR> &#060;td&#062;&#060;asp:placeholder id="plh" Runat="server"&#062;&#060;/asp:placeholder&#062;&#060;/td&#062;<BR> &#060;/tr&#062;<BR> &#060;/table&#062;<BR><BR>code behind<BR><BR> plh.Controls.Clear()<BR> For i = 0 To rolearr.Count - 1<BR> For j = 0 To indarr.Count - 1<BR> If Trim(rolearr.Item(i)) = Trim(indarr.Item(j)) Then<BR> flag = True<BR> Exit For<BR> End If<BR> Next<BR> objCheckBox = New CheckBox<BR> objCheckBox.Checked = flag<BR> objCheckBox.ID = "rolearr" & i<BR> objCheckBox.Text = "ddd" &#039; objCheckBox.AutoPostBack = True<BR><BR> plh.Controls.Add(objCheckBox)<BR>

  2. #2
    Join Date
    Dec 1969

    Default RE: Checkboxes in placeholder

    You can try a couple of things. First off, I&#039;d try using a checkboxlist rather than individual checkboxes. A checkboxlist works a lot like a dropdownlist since it uses listitems. Using a checkboxlist, just create listitems using your loop and add them to the checkboxlist. The great thing about checkbox lists is you can databind them too. There&#039;s a couple of properties on the checkboxlist that control if you want them listed vertically/horizontally and how many per column/row.<BR><BR>The second option would be to construct a table on the fly. It&#039;s pretty straightforward but it can definitely rack up the lines of code.<BR><BR>Table tbl;<BR>TableRow row;<BR>TableCell cell;<BR><BR>tbl = new Table();<BR>row = new TableRow();<BR>tbl.Rows.Add(row);<BR>cell = new TableCell();<BR>cell.HorizontalAlign = HorizontalAlign.Right;<BR>row.Cells.Add(cell);<BR> cell.Controls.Add(myCheckBox);<BR><BR>So you can control layout with a table but it&#039;s a pain. I usually avoid this except for composite controls or when I want to inherit from TableRow.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts