Hi all,
If this quest is not belong to this forum, I am sorry.
But I think this question seem to be this forum.
My problem is while I select a dropdownlist's item and click a button but the result do not show my select dropdownlist item.
My code as follows using C#.
Is something wrong about above code, Have anyone tell me what would I do or do any one have go idea for this problem.
Thanks very much.
Jim
If this quest is not belong to this forum, I am sorry.
But I think this question seem to be this forum.
My problem is while I select a dropdownlist's item and click a button but the result do not show my select dropdownlist item.
My code as follows using C#.
Code:
protected void Page_Load(object sender, EventArgs e)
{
DropDownList1.AutoPostBack = true;
DropDownList1.Items.Clear();
DropDownList1.Items.Add(new ListItem("test1","0"));
DropDownList1.Items.Add(new ListItem("test2", "1"));
}
protected void Button1_Click(object sender, EventArgs e)
{
TextBox1.Text = DropDownList1.SelectedItem.Text;
}
protected void DropDownList1_SelectedIndexChanged(object sender, EventArgs e)
{
//DropDownList1.Items.FindByValue();
DropDownList1.ClearSelection();
DropDownList1.Items.FindByValue(DropDownList1.SelectedValue).Selected = true;
TextBox1.Text = DropDownList1.SelectedValue;
}
Thanks very much.
Jim
Comment