Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. Web Development
  3. ASP.NET
  4. How to create a table for Placeholder controls

How to create a table for Placeholder controls

Scheduled Pinned Locked Moved ASP.NET
questiondesigntutorial
1 Posts 1 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • A Offline
    A Offline
    Albert83
    wrote on last edited by
    #1

    Hello, I have created a placeholder to will contain labels and textboxes based on the users choice from a dropdown. I would like to place every label and textbox in a seperate td in a table. How can I create a td for every label and textbox? Thanks. Here is part of the code: void CreateLabelsTextBoxes() { int n = Int32.Parse(NumOfQuestionsDropDown.SelectedItem.Value); // create n Labels and TextBoxes, and add them to the PlaceHolder TextBoxesHere for (int i = 0; i < n; i++) { PlaceHolder1.Controls.Add(new Label()); PlaceHolder1.Controls.Add(new TextBox()); } // Set the Text property of each Label IterateThroughChildren(this); } void IterateThroughChildren(Control parent) { int count = 1; foreach (Control c in parent.Controls) { if (c.GetType().ToString().Equals("System.Web.UI.WebControls.Label") && c.ID == null) { ((Label)c).Text = "Question" + count; count++; } Response.Write("Type= " + c.GetType() + "
    "); if (c.Controls.Count > 0) { IterateThroughChildren(c); } } } protected void NumOfQuestionsDropDown_SelectedIndexChanged(object sender, EventArgs e) { CreateLabelsTextBoxes(); }

    1 Reply Last reply
    0
    Reply
    • Reply as topic
    Log in to reply
    • Oldest to Newest
    • Newest to Oldest
    • Most Votes


    • Login

    • Don't have an account? Register

    • Login or register to search.
    • First post
      Last post
    0
    • Categories
    • Recent
    • Tags
    • Popular
    • World
    • Users
    • Groups