   Generating HTML Tables in C# [solved]
  I'm currently trying to get my StreamWriter to write some HTML. The user can use a numeric up-down to select the amount of rows and columns they wish to use, but in my code I can only make it so that the rows and columns have to be the same. Any better ways of doing this? Have a look:private void button1_Click(object sender, System.EventArgs e){FileInfo html = new FileInfo(@"C:\test.html");using (StreamWriter sw = html.CreateText()){sw.Write("<html>");sw.Write("<head>");string titleText = pageTitleBox.Text;if(titleText.Length > 1){sw.Write("<title>" + titleText + "</title>");}sw.Write("</head>");sw.Write("<body>");string body = bodyText.Text;if(body.Length > 1){sw.Write(body);}if(useTableCheckBox.Checked){if((rowsCount.Value > 1) && (columnsCount.Value > 1)){sw.Write("<table>");for(int a=0; a < columnsCount.Value; a++){for(int i=0; i < rowsCount.Value; i++){sw.Write("<tr>");sw.Write("<td>row {0}, cell {1} </td>", i, a);sw.Write("</tr>");}}sw.Write("</table>");}}sw.Write("</body>");sw.Write("</html>");}}[Edited by - GreenGiant on June 21, 2006 6:14:54 PM]
  I think you need to reverse the order of your loops, so I think you should have:for(int i=0; i < rowsCount.Value; i++){sw.Write("<tr>");for(int a=0; a < columnsCount.Value; a++){sw.Write("<td>row {0}, cell {1} </td>", i, a);}sw.Write("</tr>");};  Aha! Thanks a lot -Thork-, works correctly now. ++   