BlaDrzz BlaDrzz - 1 year ago 81 Question

ASP.NET & html ID adding

I want to make a big table with 100 cells and I did that by using the "insert table" option but when you do that the td's have no ID's to them so I can't talk with them in code. Now I'm just making a small part of what will later be a table with 1000's of cells.

I was thinking of something like:

Dim i As Integer
For i = 0 To 100
(What do I put here?).Attributes.Add(ClientID, "td" & i.ToString)

My HTML looks like:

<table class="style1">
<td id="td1" runat="server">
<td id="td2" runat="server">

but then I have 100 td's not just 3.

Any suggestions?

Answer Source

Try something like this. You have to make the table accessible to the server side.

<table class="style1" runat="server" id="theTable">

Dim row as New TableRow()

Dim i As Integer
For i = 0 To 100
  Dim cell as New TableCell()
  cell.Attributes.Add(ClientID, "td" & i.ToString)
Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download