我有<td>
包含文字。
<td width="60%" id="SpeciesName" runat = "server" ><b><%#showData(Container.DataItem, "Name")%></b></td>
我正在尝试获取SpeciesName' from the code behind, and Add it in a String list. I was capable of doing so for
asp:Textbox , but not for
的内联文字。
这是vb.net背后的代码
Private Shared Function getInputValues(ByVal currItem As RepeaterItem) As List(Of String())
Dim Input As String = "SpeciesName"
Dim alParams As New List(Of String())(1)
Dim txtCurrent As TableCell = CType(currItem.FindControl(lstInput), TableCell)
If txtCurrent.Text.Trim <> "" And txtCurrent.Text.Trim <> "0" Then
alParams.Add(New String() {Input, txtCurrent.Text.Trim, "int"})
End If
Return alParams
End Function
提前致谢!
答案 0 :(得分:1)
编辑:我刚刚解决了这个问题,这有两个问题。 1)txtCurrent
应声明为HtmlTableCell而不是TableCell。
2)我应该得到的不是文本的innertext。
这里是更新后的代码:
Private Shared Function getInputValues(ByVal currItem As RepeaterItem) As List(Of String())
Dim Input As String = "SpeciesName"
Dim alParams As New List(Of String())(1)
Dim txtCurrent As HtmlTableCell = CType(currItem.FindControl(lstInput), HtmlTableCell)
If txtCurrent.InnerText.Trim <> "" And txtCurrent.InnerText.Trim <> "0" Then
alParams.Add(New String() {Input, txtCurrent.InnerText.Trim, "int"})
End If
Return alParams
End Function