Dynamically Inserting an ID to Each Row

S

sling blade

I am creating a table using a datalist and I want to add an ID to the
html tag <tr> of each row created (eg <tr id="1">). I have a JavaScript
function which will change the back color of each row based on its ID.

I have tried using the OnItemCreated event to add an ID to the row.
Here is the code I have tried.

Public Sub Item_Created(ByVal s As Object, ByVal e As
DataListItemEventArgs)

e.Item.ID = "1"

End Sub


This is not working; does anyone if this is possible, and if it is,
what I am doing wrong?
 
S

sling blade

I asked too quickly as I found the answer in a book.

It turns out I need to build the table as a string in the code behind.
By doing this I can query the dataset to find the information I need
and I will use that info to create my tabel including the ID's. Then I
insert the string with the display.InnerHTML method.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,769
Messages
2,569,580
Members
45,054
Latest member
TrimKetoBoost

Latest Threads

Top