public void Forms_Inventory(string sql) { _ds = Utilities.Getds(sql); DataTable dt = new DataTable(); dt.Columns.AddRange(new DataColumn[2] { new DataColumn("Name", typeof(string)), new DataColumn("Department",typeof(string)) }); dt.Rows.Add("Brian", "IT"); dt.Rows.Add("Ed", "Help Desk"); dt.Rows.Add("Peter", "Engineering"); dt.Rows.Add("Scott", "Engineering"); StringBuilder sb = new StringBuilder(); //Add Table Header sb.Append("<tr>"); foreach (DataColumn column in dt.Columns) { sb.Append("<th style='background-color: #3366ff;border: 1px solid #000'>" + column.ColumnName + "</th>"); } sb.Append("</tr>"); //Add Table Rows foreach (DataRow row in dt.Rows) { sb.Append("<tr>"); //Add Table Columns foreach (DataColumn column in dt.Columns) { sb.Append("<td style='width:100px;border: 1px solid #ccc'>" + row[column.ColumnName].ToString() + "</td>"); } sb.Append("</tr>"); } PlaceHolder plc = new PlaceHolder(); plc = (PlaceHolder)FindControl("plcInventory"); plc.Controls.Add( new Literal { Text = sb.ToString() }); }
var
This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)