我正在尝试将templateFields我的 gridview 的值添加到List(Of String). 这些templateFields由 2 组成Labels。我想要实现的是
为了能够遍历 的每一行
GridView,获取重复的 templateField 值。将行的
TemplateFields1值存储在字符串中。将该字符串添加到字符串列表中。
这是我的代码:
For Each row As GridViewRow In GridView1.Rows`
Dim stri As String
Dim ttt As Label = DirectCast(row.FindControl("Title"), Label)
Dim desc As Label = DirectCast(row.FindControl("lblDescription"), Label)
stri = ttt.Text.ToString & desc.Text.ToString
Dim list As New List(Of String)
While (stri <> Nothing)
list.Add(stri) ' Add every new string in a new index of the list
End While
Next
因此,在while循环中,将stri其存储在list(0)然后继续for loop,获取下一个并将其存储在新的同时保持stri索引中,依此类推,直到所有完成。list(1)list(0)templateField stri
有什么想法或建议吗?