I need to convert a list into tabular format. I tried using normal HTML code but didnt work. I need 2 cols. in the table. This is a aspx.cs file.
Please help me with this as i am a newbie.
The list code is given below:
private void AddCategoryToMenu(string title) { HtmlAnchor a = new HtmlAnchor(); a.InnerHtml = Server.HtmlEncode(" " + title) + " "; a.HRef = "#" + Utils.RemoveIllegalCharacters(title); a.Attributes.Add("rel", "directory"); HtmlGenericControl li = new HtmlGenericControl("img align=middle src=images/icons/" + title ); li.Controls.Add(a); ulMenu.Controls.Add(li); }
|
Abhijit PPosted Jul 15, 2009, 1:00 AM
Niradhip ChakrabortyPosted Jul 14, 2009, 10:43 PM
You can create it using javascript:
Here is my html table code:
<tr>
<td style="padding-left: 15px">
<div style="overflow-y: auto; height: 85px; width: 280px;" style="padding-left: 05px">
<asp:Table ID="tblBoothPersonal" CellPadding="0" CellSpacing="0" runat="server" onclick="SelectBoothPersonal(event);">
asp:Table>
div>
td>
tr>
//Javascript code.
function EnterBoothpersonal()
{
var tbl = document.getElementById('tblBoothPersonal');
var mytablebody = document.createElement("TBODY");
var hidfirstname;
var row = document.createElement("TR");
row.setAttribute('id', document.getElementById("txtBoothFirstName").value)
//here I am creating first column
var NewCell = document.createElement("TD");
var Fname = document.getElementById("txtBoothFirstName").value;
var textNode = document.createTextNode(Fname);
NewCell.appendChild(textNode);
NewCell.setAttribute('width','130px');
row.appendChild(NewCell);
//here I am creating second column
var NewCell = document.createElement("TD");
var CallSign = document.getElementById("txtBoothCallSign").value;
var textNode = document.createTextNode(CallSign)
NewCell.appendChild(textNode);
NewCell.setAttribute('width','75px');
row.appendChild(NewCell);
mytablebody.appendChild(row);
tbl.appendChild(mytablebody);
}
Note: I have used txtBoothFirstName and txtBoothCallSign to create the table.You can use your list element and traverse through a loop to get next row.