更新时间:2023-10-05 22:54:04
http://www.mikesdotnetting.com/Article/64/Bind-Data-From -a-SqlDataSource-to-a-label [ ^ ]
创建服务器端文本框控件< asp:textbox id = txtName runat = server xmlns:asp = #unknown > < / asp:textbox >
创建数据源< asp:SqlDataSource ID = SqlDataSource1 runat = 服务器
ConnectionString = < ;%
ConnectionStrings:MyConnectionString %>
SelectCommand = SELECT * FROM [PersonalDetails] >
< / asp:SqlDataSource >
写在页面加载事件的代码隐藏页面上写下面的代码
受保护的 Sub Page_Load( ByVal sender 正如 对象, ByVal e As System.EventArgs)句柄 我。加载
Dim dv As DataView = DirectCast (SqlDataSource1。选择(DataSourceSelectArguments.Empty),DataView)
对于 每个 drv 作为 DataRowView 在 dv
txtName.Text = drv( 名称)。ToString()
下一步
结束 Sub
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?.
Thankyou,
http://www.mikesdotnetting.com/Article/64/Bind-Data-From-a-SqlDataSource-to-a-Label[^]
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]" > </asp:SqlDataSource>
write in codebehind page on Page load event write the below codeProtected 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() Next End Sub