Click here to Skip to main content
15,795,937 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Dear Friends,

I am making WebPage which store detail of Client in SqlDataSource.I am using TextBox for Name,Address,Contact No.. I want to know how we can bind TextBox to SqlDataSource?.

rkthiyagarajan 25-Sep-11 4:11am    
If you want insert the data?

create a server side text Box control
<asp:textbox id="txtName" runat="server" xmlns:asp="#unknown"></asp:textbox>

create a datasource
<asp:SqlDataSource ID="SqlDataSource1" runat="server"
ConnectionString="<%$ ConnectionStrings:MyConnectionString %>"
SelectCommand="SELECT * FROM [PersonalDetails]" >

write in codebehind page on Page load event write the below code
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
          txtName.Text = drv("Name").ToString()
End Sub
Share this answer

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900