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:
C#
privatevoidAddCategoryToMenu(string title)
{
HtmlAnchor a = new HtmlAnchor();
a.InnerHtml = Server.HtmlEncode(" " + title) + "<BR>";
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);
}
2 Answers
Know the answer? Post it. Somebody with the same question will find it here.
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.
Niradhip ChakrabortyRank #428 · 5.8K pointsPosted Jul 14, 2009, 6:43 PM EDT
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.
Abhijit P2 pointsPosted Jul 14, 2009, 9:00 PM EDT