【发布时间】:2013-04-02 14:24:09
【问题描述】:
这些属性可以组合成一行vb代码吗?
e.Row.Cells(1).Attributes.Add("id", "MyID")
e.Row.Cells(1).Attributes.Add("class", "MyCLASS")
【问题讨论】:
标签: asp.net vb.net attributes add
这些属性可以组合成一行vb代码吗?
e.Row.Cells(1).Attributes.Add("id", "MyID")
e.Row.Cells(1).Attributes.Add("class", "MyCLASS")
【问题讨论】:
标签: asp.net vb.net attributes add
不使用框架。如果真的需要一行行的话,写个方法吧……
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
【讨论】: