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 Access Dynamicaly created controls

How to Access Dynamicaly created controls

Scheduled Pinned Locked Moved ASP.NET
csharpasp-netdesigntutorialquestion
2 Posts 2 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.
  • N Offline
    N Offline
    naresh_pandey13
    wrote on last edited by
    #1

    Hi all, i m asking in case of ASP.Net... where in the page i m dynamically creating Table & inside tables i m adding text box & drop down combo as literal controls... and then i add the Table to page's controls collection Now i call the function which creates the dynamic table .. in Page Load it works fine for 1st time... but during Post Back its not creatig the page again nor i can change/set the value inside the text box dynamically. how can i access the values inside the Text Boxes the code is something like this namespace Motel { public class WebForm5 : System.Web.UI.Page { //Variables declarations here.... private void Page_Load(object sender, System.EventArgs e) { if(this.IsPostBack == true) { tot1 = (int.Parse(Request["dpersonsid"])); tot0 = (int.Parse(Request["dpid"])); if(tot1 <= 1) { tot2=int.Parse(Request["rent1"].ToString()) ; } else { tot2=int.Parse(Request["rent2"].ToString()) ; } int tot3 = (tot0)*(tot2); this.total.Text = tot3.ToString(); TextBox1.Text = tot3.ToString(); } else { //if not post back setPage(); } void setPage() { while(areader.Read()) { tb=new Table(); TableRow tr=new TableRow(); TableCell tcell=new TableCell(); tcell.Controls.Add(new LiteralControl("Room Type "+areader["RoomType"].ToString())); tr.Cells.Add(tcell); tb.Rows.Add(tr); myPlaceHolder.Controls.Add(tb); dpRooms = new DropDownList(); dpRooms.AutoPostBack =true; dpRooms.ID = "dpid"; dpRooms.Items.Add(i.ToString()); tcell=new TableCell(); tcell.Controls.Add(dpRooms); tr.Cells.Add(tcell); dpersons = new DropDownList(); dpersons.AutoPostBack = true; dpersons.ID = "dpersonsid"; dpersons.Items.Add("1");dpersons.Items.Add("2"); dpersons.Width = 70; tcell=new TableCell(); tcell.Controls.Add((dpersons)) ; tr.Cells.Add(tcell); total = new TextBox() ; total.ID = "totalid"; total.Enabled = true; total.AutoPostBack =true; tcell=new TableCell(); tcell.Controls.Add((total)) ; tr.Cells.Add(tcell); } tb.Rows.Add(tr); myPlaceHolder.Controls.Add(tb); Page.EnableViewState = true; return; Plz Reply ASAP. Tahnx a lot :-O This is naresh

    A 1 Reply Last reply
    0
    • N naresh_pandey13

      Hi all, i m asking in case of ASP.Net... where in the page i m dynamically creating Table & inside tables i m adding text box & drop down combo as literal controls... and then i add the Table to page's controls collection Now i call the function which creates the dynamic table .. in Page Load it works fine for 1st time... but during Post Back its not creatig the page again nor i can change/set the value inside the text box dynamically. how can i access the values inside the Text Boxes the code is something like this namespace Motel { public class WebForm5 : System.Web.UI.Page { //Variables declarations here.... private void Page_Load(object sender, System.EventArgs e) { if(this.IsPostBack == true) { tot1 = (int.Parse(Request["dpersonsid"])); tot0 = (int.Parse(Request["dpid"])); if(tot1 <= 1) { tot2=int.Parse(Request["rent1"].ToString()) ; } else { tot2=int.Parse(Request["rent2"].ToString()) ; } int tot3 = (tot0)*(tot2); this.total.Text = tot3.ToString(); TextBox1.Text = tot3.ToString(); } else { //if not post back setPage(); } void setPage() { while(areader.Read()) { tb=new Table(); TableRow tr=new TableRow(); TableCell tcell=new TableCell(); tcell.Controls.Add(new LiteralControl("Room Type "+areader["RoomType"].ToString())); tr.Cells.Add(tcell); tb.Rows.Add(tr); myPlaceHolder.Controls.Add(tb); dpRooms = new DropDownList(); dpRooms.AutoPostBack =true; dpRooms.ID = "dpid"; dpRooms.Items.Add(i.ToString()); tcell=new TableCell(); tcell.Controls.Add(dpRooms); tr.Cells.Add(tcell); dpersons = new DropDownList(); dpersons.AutoPostBack = true; dpersons.ID = "dpersonsid"; dpersons.Items.Add("1");dpersons.Items.Add("2"); dpersons.Width = 70; tcell=new TableCell(); tcell.Controls.Add((dpersons)) ; tr.Cells.Add(tcell); total = new TextBox() ; total.ID = "totalid"; total.Enabled = true; total.AutoPostBack =true; tcell=new TableCell(); tcell.Controls.Add((total)) ; tr.Cells.Add(tcell); } tb.Rows.Add(tr); myPlaceHolder.Controls.Add(tb); Page.EnableViewState = true; return; Plz Reply ASAP. Tahnx a lot :-O This is naresh

      A Offline
      A Offline
      Aryadip
      wrote on last edited by
      #2

      Hi Naresh, Checkout your previous request... I have been late but have answered your query to the best of my knowledge... regards, Aryadip. Cheers !! and have a Funky day !!

      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