2010-11-12 40 views

回答

2

由於您的標籤位於GridView中,因此您必須通過GridView中的行。您可以使用GridView的RowDataBound事件遍歷行並訪問內部控件的值。事情是這樣的..

 Protected Sub GridView1_RowDataBound(ByVal sender As Object, ByVal e As GridViewRowEventArgs) 
     If e.Row.RowType = DataControlRowType.DataRow Then 
       If Not e.Row.DataItem Is Nothing Then 
        Dim lbl As Label = CType(e.Row.Cells(1).FindControl("YourLabelName"), Label) 
        If lbl.Text = "Copy" Then 
         TextBox1.Text = lbl.Text 
        End If 
       End If 
     End If 

末次

,或者如果你想複製特定行的值,然後

Dim lbl As Label = DirectCast(DirectCast(e.Item.FindControl("GridView1"), GridView).Rows(0).FindControl("YourLabelName"), Label) 
    TextBox1.Text = lbl.Text 
相關問題