return to Other Downloads menu
You can't do a FindControl of a BoundField |
Because boundfields are assigned names by .net, you can't do a FindControl of a BoundField by name. Instead - you need to find controls using hardcoded field numbers. It's ugly and clumsy, but works in a pinch. See the example below. Sub Find_my_DetailsView_BoundField_Controls() Dim i As Integer = 0 Dim MyTBX As TextBox Dim MyLBL As Literal For Each dvr As DetailsViewRow In DetailsView1.Rows i = i + 1 If dvr.Cells.Count = 2 Then If dvr.Cells(1).Controls.Count > 0 Then Try MyTBX = dvr.Cells(1).Controls(0) ' test to see if this control is a 'TEXTBOX' - if not - this will fail the try/catch Select Case i Case 9 TBX_field1 = MyTBX Case 10 TBX_field2 = MyTBX Case 11 TBX_field3 = MyTBX Case 12 TBX_field4 = MyTBX End Select Catch End Try End If End If Next End Sub |