I have a dropdown listbox whose datasource is a dictionary.
When I have added items to the list and try to select an item from the list, the item I selected does not get the focus. And this comes when I changed the property autopostback to true.
Here are some of the codes which are relevant to it.
When I have added items to the list and try to select an item from the list, the item I selected does not get the focus. And this comes when I changed the property autopostback to true.
Here are some of the codes which are relevant to it.
Code:
protected void Page_Load(object sender, EventArgs e) { if (!IsPostBack) LoadList(); } private void LoadList() { cbxProduct.DataSource = Supplies; if (!IsPostBack) { Supplies.Add("Banana", 1); Supplies.Add("Annana", 1); cbxProduct.DataTextField = "Key"; cbxProduct.DataValueField = "Value"; } cbxProduct.DataBind(); } public Dictionary<string, int> Supplies { get { if (Page.Session["supplies"] == null) { Dictionary<string, int> supplies = new Dictionary<string, int>(); Page.Session["supplies"] = supplies; } return (Dictionary<string, int>)Page.Session["supplies"]; } set { Page.Session["supplies"] = value; } }
Comment