Binding multiple Dropdowns and textfields

1artemka

New Member
In my project I have 2 dropdowns 1 listbox and 1 textbox. I Have already bound the 2 dropdowns together "PostalDropDown" and "CityDropDown" from the database and it works fine, Then i bind the listbox also to the previous dropdowns and it works fine also!My question here i still have the last Textbox which i want it to display the name which is also bound to the results of dropdowns.I cannot figur it out because the textbox does not have the SelectValue property, so I cannot assign it like i did with my dropdowns or listbox like i did:\[code\] if (!IsPostBack) { IEnumerable<Tuple<string, string, string, string>> data = http://stackoverflow.com/questions/12616608/GetData(); DropDownListPostal.DataSource = data.Select(tuple => tuple.Item1).Distinct().ToList(); DropDownListPostal.DataBind(); DropDownListCity.DataValueField ="Item1"; DropDownListCity.DataTextField = "Item2"; DropDownListCity.DataSource = data; DropDownListCity.DataBind(); ListBox1.DataValueField = "item1"; ListBox1.DataTextField = "Item4"; ListBox1.DataSource = data; ListBox1.DataBind(); } }\[/code\]and then i view the result on this on the selectedindexchanged on first dropdown:\[code\] protected void DropDownListPostal_SelectedIndexChanged1(object sender, EventArgs e) { //DropDownListPostal.ClearSelection(); ListBox1.ClearSelection(); DropDownListCity.ClearSelection(); var postal = DropDownListPostal.SelectedValue; var listItem = DropDownListCity.Items.FindByValue(postal); var street = ListBox1.Items.FindByValue(postal); listItem.Selected = true; street.Selected = true;\[/code\]Can anyone show me how to add the rest of the database results on a textbox? I can put the whole code for the page if you all want.Cheers
 
Back
Top