我一再碰到这个问题,并 have不出造成这一问题的原因。 我在《数据表》中有一个例外:<代码>。 由于在项目编码>清单中不存在这种价值,因而无效。
以下是一些重要信息:
- I reload listOrgs periodically when the underlying data has changed.
- The Organization.DTListAll call returns 2 Int, String pairs.
- There are no duplicate or null values in the returned data
- After the first two lines below, listOrgs.Items.Count is 0, and the Selected Value is 0
- The selected value after the DataBind operation executes is the ID value from the first row in the data
- This exception happens the very first time this code is executed after a fresh page load
listOrgs.Items.Clear();
listOrgs.SelectedValue = "0";
listOrgs.DataSource = new Organization().DTListAll(SiteID);
listOrgs.DataTextField = "OrganizationName";
listOrgs.DataValueField = "OrganizationID";
listOrgs.DataBind();