Friday, March 23, 2012

Read datasource value, send to textbox in VB script

I want to read a value from a datasource and send it to a textbox on an ASP page from the page's attached VB file.

Both the textbox and datasource exist, but I don't know the proper commands to get the datasource value and then set the textbox value to it.

Dim Text As TextBox = FormView0.FindControl("Header")

Dim SQL As String = "Select [Customer] From [Datasource]"

Datasource.SelectCommand = SQL

Oh yeah, I don't want the textbox control to be databound as shown:

Text

='<%# Eval("Customer") %>'

Hi phoenix,

ASP.NET provides many ways on Data Binding server controls. As you want to bind data to a textbox from your data table, we suggest that you should create a DataSet which contains the data talbe and filter which row and column would be selected, then evaluate the TextBox control's text property with the selected value.

Ofcause there are may other ways for you to refer, pls check these materials:

http://samples.gotdotnet.com/quickstart/aspplus/doc/webdatabinding.aspx (For Data Binding server controls)

http://samples.gotdotnet.com/quickstart/aspplus/doc/webserverctrls.aspx (For the introduction of server controls)

If this does not help you ,pls feel free to mark the post as Not Answered and reply. Thanks.

No comments:

Post a Comment