How to select second td in detailsview datarow?

uzay95 picture uzay95 · May 23, 2009 · Viewed 44.9k times · Source

I am trying create a new css for shaping my detailsview. But i couldn't reach to second td in detailsviews field rows. do you have any idea to access 2nd td?

But please imagine belov code generated by detailsview.

<table>
<thead>
...
</thead>

<tbody>
    <tr>
        <td>Name</td>
        <td><input type='text' id='txtName' /></td>
    </tr>
</tbody>
</table>

Answer

cletus picture cletus · May 23, 2009

The first question is: do you need to support IE6? If the answer is yes then you can't do it. If not the easiest solution is probably:

td + td { ... }

Even more modern (and less supported) is:

td:nth-child(2) { ... }

This presupposes that you're not willing or not able to put a class or other identifier on the second td so you can do it much more easily.