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. table at run ime

table at run ime

Scheduled Pinned Locked Moved ASP.NET
help
4 Posts 3 Posters 1 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.
  • J Offline
    J Offline
    jainiraj
    wrote on last edited by
    #1

    I want to generate a table at run time in a panel.I want 5 columns in each row. here is code- Table tbl = new Table(); tbl.Style.Add("text-align", "center"); foreach (DataRow dr in dt.Rows) { TableRow tr = new TableRow(); TableCell tc1 = new TableCell(); TableCell tc2 = new TableCell(); TableCell tc3 = new TableCell(); TableCell tc4 = new TableCell(); TableCell tc5 = new TableCell(); tc1.BackColor = Color.WhiteSmoke; tc2.BackColor = Color.WhiteSmoke; tc3.BackColor = Color.WhiteSmoke; tc4.BackColor = Color.WhiteSmoke; tc5.BackColor = Color.WhiteSmoke; tc1.Width = 185; tc2.Width = 185; tc3.Width = 185; tc4.Width = 185; tc5.Width = 185; //tc1.BorderWidth = 1; //tc2.BorderWidth = 1; //tc3.BorderWidth = 1; //tc4.BorderWidth = 1; //tc5.BorderWidth = 1; tc1.Style.Add("text-align","center"); tc2.Style.Add("text-align","center"); tc3.Style.Add("text-align","center"); tc4.Style.Add("text-align","center"); tc5.Style.Add("text-align","center"); tr.Width = 926; tr.Height = 23; tr.BorderWidth = 1; tr.Controls.Add(tc1); tr.Controls.Add(tc2); tr.Controls.Add(tc3); tr.Controls.Add(tc4); tr.Controls.Add(tc5); //tc.Width = 110; //tc.Height = 22; //tc.Font.Size = 40; tc1.Text = "Niraj jain"; //tr.Controls.Add(tc); tbl.Controls.Add(tr); } Panel5.Controls.Add(tbl); but this table is not generating inside the panel.It is below the panel. plz help....

    P B 2 Replies Last reply
    0
    • J jainiraj

      I want to generate a table at run time in a panel.I want 5 columns in each row. here is code- Table tbl = new Table(); tbl.Style.Add("text-align", "center"); foreach (DataRow dr in dt.Rows) { TableRow tr = new TableRow(); TableCell tc1 = new TableCell(); TableCell tc2 = new TableCell(); TableCell tc3 = new TableCell(); TableCell tc4 = new TableCell(); TableCell tc5 = new TableCell(); tc1.BackColor = Color.WhiteSmoke; tc2.BackColor = Color.WhiteSmoke; tc3.BackColor = Color.WhiteSmoke; tc4.BackColor = Color.WhiteSmoke; tc5.BackColor = Color.WhiteSmoke; tc1.Width = 185; tc2.Width = 185; tc3.Width = 185; tc4.Width = 185; tc5.Width = 185; //tc1.BorderWidth = 1; //tc2.BorderWidth = 1; //tc3.BorderWidth = 1; //tc4.BorderWidth = 1; //tc5.BorderWidth = 1; tc1.Style.Add("text-align","center"); tc2.Style.Add("text-align","center"); tc3.Style.Add("text-align","center"); tc4.Style.Add("text-align","center"); tc5.Style.Add("text-align","center"); tr.Width = 926; tr.Height = 23; tr.BorderWidth = 1; tr.Controls.Add(tc1); tr.Controls.Add(tc2); tr.Controls.Add(tc3); tr.Controls.Add(tc4); tr.Controls.Add(tc5); //tc.Width = 110; //tc.Height = 22; //tc.Font.Size = 40; tc1.Text = "Niraj jain"; //tr.Controls.Add(tc); tbl.Controls.Add(tr); } Panel5.Controls.Add(tbl); but this table is not generating inside the panel.It is below the panel. plz help....

      P Offline
      P Offline
      Paddy Boyd
      wrote on last edited by
      #2

      Any particular reason you're not using a gridview?

      1 Reply Last reply
      0
      • J jainiraj

        I want to generate a table at run time in a panel.I want 5 columns in each row. here is code- Table tbl = new Table(); tbl.Style.Add("text-align", "center"); foreach (DataRow dr in dt.Rows) { TableRow tr = new TableRow(); TableCell tc1 = new TableCell(); TableCell tc2 = new TableCell(); TableCell tc3 = new TableCell(); TableCell tc4 = new TableCell(); TableCell tc5 = new TableCell(); tc1.BackColor = Color.WhiteSmoke; tc2.BackColor = Color.WhiteSmoke; tc3.BackColor = Color.WhiteSmoke; tc4.BackColor = Color.WhiteSmoke; tc5.BackColor = Color.WhiteSmoke; tc1.Width = 185; tc2.Width = 185; tc3.Width = 185; tc4.Width = 185; tc5.Width = 185; //tc1.BorderWidth = 1; //tc2.BorderWidth = 1; //tc3.BorderWidth = 1; //tc4.BorderWidth = 1; //tc5.BorderWidth = 1; tc1.Style.Add("text-align","center"); tc2.Style.Add("text-align","center"); tc3.Style.Add("text-align","center"); tc4.Style.Add("text-align","center"); tc5.Style.Add("text-align","center"); tr.Width = 926; tr.Height = 23; tr.BorderWidth = 1; tr.Controls.Add(tc1); tr.Controls.Add(tc2); tr.Controls.Add(tc3); tr.Controls.Add(tc4); tr.Controls.Add(tc5); //tc.Width = 110; //tc.Height = 22; //tc.Font.Size = 40; tc1.Text = "Niraj jain"; //tr.Controls.Add(tc); tbl.Controls.Add(tr); } Panel5.Controls.Add(tbl); but this table is not generating inside the panel.It is below the panel. plz help....

        B Offline
        B Offline
        Baran M
        wrote on last edited by
        #3

        You have used Controls.Add method everywhere. Use TableRow.Cells.Add([New Control]") method appropriately. Ex: tr.Cells.Add(tc1); tb1.Rows.Add(tr); I have tried it and its working :)

        B 1 Reply Last reply
        0
        • B Baran M

          You have used Controls.Add method everywhere. Use TableRow.Cells.Add([New Control]") method appropriately. Ex: tr.Cells.Add(tc1); tb1.Rows.Add(tr); I have tried it and its working :)

          B Offline
          B Offline
          Baran M
          wrote on last edited by
          #4

          You can use GridView instead of creating your own. Compared to your own table gridview is a wise control.

          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