Adding Row To a Table ASP.NET C# Microsoft Visual Studio -


i created table these headers. how use while loop , add empty rows dynamically on page load. if want 40 empty row 3 cells each, how use while loop , add rows?

asp.net c# microsoft visual studio

    tablerow tr = new tablerow();      tablecell tcel = new tablecell();     tcel.text = "id";     tr.cells.add(tcel);      tablecell tcel1 = new tablecell();     tcel1.text = "work";     tr.cells.add(tcel1);      tablecell tcel2 = new tablecell();     tcel2.text = "email";     tr.cells.add(tcel2);      table1.rows.add(tr); 

pretty simple. append these:

var j = 0; while (j++ < 40) {     var k = 0;     var emptyrow = new tablerow();     while (k++ < 3)     {         var emptycell = new tablecell();         emptycell.text = "|empty cell|";         emptyrow.cells.add(emptycell);     }     table1.rows.add(emptyrow); } 

Comments

Popular posts from this blog

user interface - Python attempting to create a simple gui, getting "AttributeError: 'MainMenu' object has no attribute 'intro_screen'" -

jquery - Common JavaScript snippet to share files on Google Drive, Dropbox, Box.net or SkyDrive -

Android Gson.fromJson error -