views:

25

answers:

1

I am using c# with asp.net and SQL Server 2005 as backend. I want to use dropdown list control in a form to populate a textbox. The dropdown control is linked to a column in the database. How can I code this in c#?

A: 

Do you mean this

 protected void Page_Load(object sender, EventArgs e)
 {
 DropDownList1.datasource = list;
 DropDownList1.datBind();
 }

 protected void DropDownList1_OnSelectedIndexChanged(object sender, EventArgs e)
 {
      TextBox1.Text = DropDownList1.SelectedValue;
 }

Or this

 protected void DropDownList1_OnSelectedIndexChanged(object sender, EventArgs e)
 {
      TextBox t = new TextBox();
      t.Text = DropDownList1.SelectedValue;
      body.InnerHtml.add(t);
 }
Nasser Hadjloo