DbSelect selMeeting = new DbSelect("COM_MEETING A", "A"); selMeeting.Select("A.ROW_ID,A.MEETING_TOPIC"); selMeeting.Where("A.STATUS = 'R'"); DataTable dtMeeting = DbAccess.GetDataTable(selMeeting.GetSql()); if (dtMeeting.Rows.Count > 0) { ddlMeetingTopic.DataSource = dtMeeting; ddlMeetingTopic.DataValueField = "ROW_ID"; ddlMeetingTopic.DataTextField = "MEETING_TOPIC"; ddlMeetingTopic.DataBind(); }
代码如上。查到如下数据,数据可以绑定成功,但会出现异常。
你只要Google一下,“has a SelectedValue which is invalid because it does not exist in the list of items”
就会发现铺天盖地都是相关的问题,MSDN里面也有的。
建议检查一下代码中使用ddlMeetingTopic.SelectedValue的地方