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. adding table to div at runtime.. but when i want to access it using findcontrol method its returning null

adding table to div at runtime.. but when i want to access it using findcontrol method its returning null

Scheduled Pinned Locked Moved ASP.NET
sysadmin
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.
  • S Offline
    S Offline
    shailendra_csp
    wrote on last edited by
    #1

    Hi all I am having following code.. #region Dynamically added control to the table TableRow tr=null; int cols = 0; if (multiFile.Files.Length > 0) { msg.InnerText = "These Files Uploaded Successfully. [" + multiFile.Files.Length + " files]. "; int counter=0; foreach (UploadedFile file in multiFile.Files) { //this for display 5 image in one row if (cols % 5 == 0) { tr = new TableRow(); } string FolderPath = Server.MapPath("Images"); file.MoveTo(FolderPath + "\\" + file.FileName, MoveToOptions.Overwrite); Image myImage = new Image(); myImage.ImageUrl = "~/Images/" + file.FileName; myImage.Height = 150; myImage.Width =150; //create new inner table so that we can add all fields in sequence Table innerTable = new Table(); //create new row and add images TableRow innerTr1 = new TableRow(); TableCell innerTc11 = new TableCell(); innerTc11.ColumnSpan = 2; innerTc11.Controls.Add(myImage); innerTr1.Controls.Add(innerTc11); //create row 2 TableRow innerTr2 = new TableRow(); //create control to add in row 2 and column 1 DropDownList ddlEyeType = new DropDownList(); ddlEyeType.ID = "ddlEyeType_" + counter.ToString(); ddlEyeType.Items.Add(new ListItem("", "-1")); ddlEyeType.Items.Add(new ListItem("Left Eye", "1")); ddlEyeType.Items.Add(new ListItem("Right Eye", "2")); //create column 1 for row 2 TableCell innerTc21 = new TableCell(); innerTc21.Controls.Add(ddlEyeType); //create control to add in row 2 and column 2 DropDownList ddlEyePart = new DropDownList(); ddlEyePart.ID = "ddlEyePart_" + counter.ToString(); counter++; ddlEyePart.Items.Add(new ListItem("", "-1")); ddlEyePart.

    M 1 Reply Last reply
    0
    • S shailendra_csp

      Hi all I am having following code.. #region Dynamically added control to the table TableRow tr=null; int cols = 0; if (multiFile.Files.Length > 0) { msg.InnerText = "These Files Uploaded Successfully. [" + multiFile.Files.Length + " files]. "; int counter=0; foreach (UploadedFile file in multiFile.Files) { //this for display 5 image in one row if (cols % 5 == 0) { tr = new TableRow(); } string FolderPath = Server.MapPath("Images"); file.MoveTo(FolderPath + "\\" + file.FileName, MoveToOptions.Overwrite); Image myImage = new Image(); myImage.ImageUrl = "~/Images/" + file.FileName; myImage.Height = 150; myImage.Width =150; //create new inner table so that we can add all fields in sequence Table innerTable = new Table(); //create new row and add images TableRow innerTr1 = new TableRow(); TableCell innerTc11 = new TableCell(); innerTc11.ColumnSpan = 2; innerTc11.Controls.Add(myImage); innerTr1.Controls.Add(innerTc11); //create row 2 TableRow innerTr2 = new TableRow(); //create control to add in row 2 and column 1 DropDownList ddlEyeType = new DropDownList(); ddlEyeType.ID = "ddlEyeType_" + counter.ToString(); ddlEyeType.Items.Add(new ListItem("", "-1")); ddlEyeType.Items.Add(new ListItem("Left Eye", "1")); ddlEyeType.Items.Add(new ListItem("Right Eye", "2")); //create column 1 for row 2 TableCell innerTc21 = new TableCell(); innerTc21.Controls.Add(ddlEyeType); //create control to add in row 2 and column 2 DropDownList ddlEyePart = new DropDownList(); ddlEyePart.ID = "ddlEyePart_" + counter.ToString(); counter++; ddlEyePart.Items.Add(new ListItem("", "-1")); ddlEyePart.

      M Offline
      M Offline
      Muhammad Mazhar
      wrote on last edited by
      #2

      HTML elements containing runat server attribute can be accessed on server side. You can give a try by providing id and runat=server on your table being added.

      Share your experience with others Check my Blog...

      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