开发者

textbox in asp.net using c#

开发者 https://www.devze.com 2023-01-06 20:31 出处:网络
Can i bind my data with textbox in asp.net using c# sorry to ask this silly question if yes tha开发者_开发技巧n how to bind it

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

if yes tha开发者_开发技巧n 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 ?


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


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.


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!

0

精彩评论

暂无评论...
验证码 换一张
取 消