user383664
user383664

Reputation: 107

textbox in asp.net using c#

Can i bind my data with textbox in asp.net using c# sorry to ask this silly question

if yes than how to bind it as if we use VC# the text box has the option data binding in property ''

in asp.net i am not getting it

plz can any help me out ?

Upvotes: 0

Views: 1481

Answers (3)

Fairy_G
Fairy_G

Reputation: 417

To store the value of the database providers to textbox, the process could be like this,

 DataSet ds = mySqlDataAdapter.Fill(ds,"xyz");

 txtName.Text = ds.Tables[0].Rows[0]["NameField"].ToString();
 txtField2.Text = ds.Tables[0].Rows[0]["Field2"].ToString();

Even from the Data Reader you can bind the data to textbox in the similar manner.

Upvotes: 0

Brett
Brett

Reputation: 4061

Your C# function could be:

void Page_Load() { 
 txt1.Text = "Hello World"; 
}

Your ASP.NET code could be:

<form runat="server">
<asp:TextBox id="txt1" runat="server" />
</form>

Hope that helps!

Upvotes: 0

John Saunders
John Saunders

Reputation: 161831

Yes, you can. It's been possible since ASP.NET 1.0.

Upvotes: 1

Related Questions