DropDownList in FormView - Show Selected Item in a Label
Posted on 2006-11-01
I have a dropdownlist (DropDownList1) in a formview (FormView1).
How do I show the selected item in a label (Label1) outside of the formview?
At the moment I have the following code but it only shows the initial dropdown value and does not update the label when the selected item changes. I realise I somehow have to incorporate the dropdown selected item change event into the code but I’ve no idea how & where.
protected override void OnInit (EventArgs e)
FormView1.ItemCreated += new EventHandler (FormView1_ItemCreated);
protected void FormView1_ItemCreated (Object sender,EventArgs e)
FormViewRow row = FormView1.Row;
DropDownList ddl = (DropDownList)row.FindControl(“DropDownList”);