Thanks Indresh
I have solved my problem and here is the code for further reference :
I have a panel and my control are inside the panel
I am trying to update the text of textbox who's name is created dynamically :
Protected Sub cbosub1_SelectedIndexChanged(ByVal sender As Object, ByVal e As System.EventArgs) Handles cbosub1.SelectedIndexChanged, cbosub2.SelectedIndexChanged, cbosub4.SelectedIndexChanged, cbosub3.SelectedIndexChanged
Dim SqlDataSource1 As New SqlDataSource()
Dim SQL As String
Dim cbo As DropDownList
cbo = sender
Dim subcode As String
Dim connectionString As String
Dim connection As SqlConnectionProtected Sub cbosub1_SelectedIndexChanged(ByVal sender As Object, ByVal e As System.EventArgs) Handles cbosub1.SelectedIndexChanged, cbosub2.SelectedIndexChanged, cbosub4.SelectedIndexChanged, cbosub3.SelectedIndexChanged
Dim ctlname = cbo.ID
ctlname = "txtstd" + Right(cbo.ID, 1)
connectionString = ConfigurationManager.ConnectionStrings("accountsConnectionString").ToString
connection = New SqlConnection(connectionString)
subcode = cbo.SelectedItem.Value
SQL = "select students from schsubcd17 where schcode=" & txtschcode.Text & " and subcode = '" & subcode & "'"
Try
connection.Open()
Dim cmd As New SqlCommand(SQL, connection)
Dim reader As SqlDataReader = cmd.ExecuteReader
Dim text1 As TextBox = CType(panelsci.FindControl(ctlname), TextBox)
While reader.Read()
text1.Text = reader.Item(0)
End While
End Sub