使用associatedheadercelllid获取标题文本

本文关键字:文本 标题 获取 associatedheadercelllid 使用 | 更新日期: 2023-09-27 18:16:37

如何使用AssociatedHeaderCellID从asp.net表对象的标题单元格中获取文本值?

我试过:

string headerCell = cell.AssociatedHeaderCellID.GetValue(); // bad code  
string headerCell = cell.AssociatedHeaderCellID.ToString(); // returns "System.String[]"

我期望返回表头的文本,如"Location"

使用associatedheadercelllid获取标题文本

From MSDN:

associatedheadercelllid属性包含一个标题单元格列表的标头信息的编程标识符TableCell控制。标题单元格标识符列表呈现为将逗号分隔的列表放入HTML元素的header属性中。

所以你应该写

string headerCell = cell.AssociatedHeaderCellID == null ? "" : 
                       string.Join(",", cell.AssociatedHeaderCellID);