2016-08-15 48 views
0

我有一個<td>包含文本。如何獲得​​來自VB.net中代碼的文本

<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將InnerText:文本框, 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 

提前感謝!

+1

你想'SpeciesName'將InnerText?即這個部分,右 - <%#showData(Container.DataItem,「Name」)%>'? – TheUknown

+0

@完全知道! – Wafae

+1

@TheUknown我剛剛解決它。謝謝! – Wafae

回答

1

編輯:我剛剛解決了這個問題,這有兩個問題。 1)應將txtCurrent聲明爲HtmlTableCell而非TableCell。

2)這是我應該得到的不是文本的內文。

這裏是更新的代碼背後:

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 
+0

加1可以自己找出解決方案 – TheUknown