这些属性可以组合成一行vb代码吗?
e.Row.Cells(1).Attributes.Add("id", "MyID")
e.Row.Cells(1).Attributes.Add("class", "MyCLASS")
答案 0 :(得分:0)
不使用框架。如果你真的需要一行,那就写一个方法......
AddIdAndClassToCell(e.Row.Cells(1), "MyId", "MyClass")
Private Sub AddIdAndClassToCell(cell, id, class)
cell.Attributes.Add("id", id)
cell.Attributes.Add("class", class)
End Sub
或者你可以做一个更通用的帮手...
Private Sub AddAttributes(cell, attributes As Dictionary(of String, String))
For Each item As KeyValuePair(Of String, String) In attributes
cell.Attributes.Add(item.Key, item.Value)
Next
End Sub