Hello I'm working with asp.net and javascript and i want to populate a dropdownlist2 with a List when dropdownlist1 is changed.
public Dictionary<string, List<string>> dict = new Dictionary<string, List<string>>();
DataTable dt = new DataTable();
dt.Columns.Add("Name");
dt.Columns.Add("Type");
foreach (DataDefinitionResponse dr in _dr)
{
if (dr.Type != "Group" && dr.Type != "File")
{
DataRow row = dt.NewRow();
row["Name"] = dr.Name;
row["Type"] = dr.Type;
dt.Rows.Add(row);
if (dr.Type == "Dropdown")
{
string[] strSplit = dr.ListValue.Split('|');
List<string> lst = new List<string>();
foreach (string word in strSplit)
{
lst.Add(word);
}
dict.Add(dr.Name, lst);
}
}
}
ddlFieldName.DataSource = dt;
ddlFieldName.DataTextField = "Name";
ddlFieldName.DataValueField = "Type";
ddlFieldName.DataBind();
ddlFieldName.ClearSelection();
Above is my code to populate the first dropdownlist w/c is ddlFieldName. As you can see i use dictionary and declared global. Now I need to populated the 2nd dropdownlist using javascript.
Can anyone help me with this.
Thx.