尝试仅访问转发器模板中的一个文本框字段

Trying to access only one textbox field inside a repeater template

  If (dr.Read) Then
            Dim thread As Integer
            thread = Convert.ToInt32(dr(0).ToString())
            For Each rItem As RepeaterItem In Repeater1.Items
                Dim txtBox As HtmlInputText = DirectCast(rItem.FindControl("messtxt"), HtmlInputText)
                If Not IsNothing(txtBox) Then
                    Dim messtxta As String = txtBox.Value
                    cmd2 = New OleDbCommand("INSERT INTO messages(content) VALUES('" & messtxta.Replace("'", "''") & "')", con)
                    cmd2.Connection = con
                    cmd2.ExecuteNonQuery()
                End If
            Next
            Response.Redirect("pals.aspx")

以上代码可以很好地用于插入目的。 除了: 问题是,如果中继器重复 x 次,那么文本框中将有 x 次插入,其中一个将是我输入的那个。

我只想插入一次。 请帮忙。

If (dr.Read) Then
        Dim thread As Integer
        Dim txtBox As HtmlInputText
        Dim messtxta As String
        thread = Convert.ToInt32(dr(0).ToString())
        For Each rItem As RepeaterItem In Repeater1.Items
            txtBox = DirectCast(rItem.FindControl("messtxt"), HtmlInputText)
         If Not IsNothing(txtBox) Then 
            IF txtBox.Value.Length > 0 THEN
               messtxta   = txtBox.Value
            END IF
         End If   
        Next

        cmd2 = New OleDbCommand("INSERT INTO messages(content) VALUES('" & messtxta.Replace("'", "''") & "')", con)
        cmd2.Connection = con
        cmd2.ExecuteNonQuery()

        Response.Redirect("pals.aspx")