Reputation: 107
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
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
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