<asp:TextBox ID="TextBox1" runat="server"></asp:TextBox>
Note: Whenever you want to access a control's parameters from codebehind, you must include the runat="server" within the opening tag of the control.
2.) Next, we create the asp:sqldatasource:
<asp:SqlDataSource ID="SqlDataSource1" runat="server"
ConnectionString="<%$ ConnectionStrings:MyConnectionString %>"
SelectCommand="SELECT * FROM [Accounts]" >
</asp:SqlDataSource>
3.) Finally, We add the codebehind. In this case we'll just use the PageLoad event.
Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
Dim dv As DataView = DirectCast(SqlDataSource1.Select(DataSourceSelectArguments.Empty), DataView)
For Each drv As DataRowView In dv
TextBox1.Text = drvSql("AccountName").ToString()
' Add as many textboxes or labels as you need
Next
End Sub
That's it!
You can use this technique with any control you see fit just as long as you include the runat="server" in the opening tag.