user1208150
user1208150

Reputation: 1

How to add rows to a table dynamically with asp.net

I want to generate a table in following fashion :

  <table>
      <tbody>
          <tr class="folder" style="-moz-user-select: none;">
              <td><div><img src="folder.png"><span>home</span></div></td>
              <td class="bytes">Folder</td>
          </tr>
          <tr class="folder hover" style="-moz-user-select: none;">
              <td><div><img src="folder.png"><span>share</span></div></td>
              <td class="bytes">Folder</td>
          </tr>
      </tbody>
  </table>​

I want to add the rows from the CS code depending on the number of entries.

Upvotes: 0

Views: 873

Answers (2)

Sebastian Siek
Sebastian Siek

Reputation: 2075

Instead of "adding elements to html table" you should consider using Repeater for data display, which would give you clean html (exactly as you want).

Then on each click you would do what you need to do (code behind) and rebind the repeater.

Hope that helps.

Upvotes: 1

Robert
Robert

Reputation: 3074

I would agree with Sebastian why not use a repeater or datalist to bind the data. What source are you using to get your data from? If your pulling the data from a SQL table here is a pretty good article on how to get you started.

http://msdn.microsoft.com/en-us/library/aa719636(v=vs.71).aspx

Upvotes: 0

Related Questions