0

C#

 for(int k = 0; k < tableAppointment.Rows[0].Cells.Count; k++)
            {
                cellID = tableAppointment.Rows[0].Cells[k];
    }

aspx

<table id="tableAppointment" runat="server">
        <tr Class="csstextheader">
            <td class="csstextheader" width="70px">
                                        </td>
            <td class="csstextheader" width="70px">
                                            <b>Time Slot&nbsp;</b>
                                        </td>
            <td ID="9"><span>C</span></td>

        </tr>
</table>

如何获取单元格 ID?

4

1 回答 1

1

试试这个

 for(int k = 0; k < tableAppointment.Rows[0].Cells.Count; k++)
 {
     var currentCell = tableAppointment.Rows[0].Cells[k];
     string ID = currentCell.Attributes["ID"]; //for this, k must be count-1, the last cell
 }

确定具有 ID 的单元格,例如最后一个单元格tableAppointment.Rows[0].Cells[2] or tableAppointment.Rows[0].Cells[Count-1]

于 2012-10-25T09:25:16.847 回答