本文介绍了SelectedIndex无效,因为它不存在于项列表中。参数名称的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述 任何人都可以请我解决这个问题....那就是我收到的错误 -----------错误---- ------------------ {'DDLShipmentType'有一个无效的SelectedIndex,因为它不存在于items.\\ n参数名称:value} -------------------- ---------------------------- 附近 cmb_ShipmentType.SelectedIndex = 0; 我在下面的代码中将selectedindex作为-1 public void PopulateShipmentType(DropDownList cmb_ShipmentType) { string Sql = 从xxx中选择a,b,其中NUIsActive = 1; 使用(DataView Source = new DataView(objDBLib.ExecuteQuery(Sql).Tables [ 0 ])) { cmb_ShipmentType.DataSource = Source; cmb_ShipmentType.DataTextField = a; cmb_ShipmentType.DataValueField = b; cmb_ShipmentType.DataBind(); cmb_ShipmentType.SelectedIndex = 0 ; } } 解决方案 在上面的情况中,Source不会返回任何行。 /> 因此无法为SelectedIndex设置值,因为无法选择。 如果有任何条目,请检查您的表。 Hi can any one please me to resolve this issue....that is i'm getting the error as -----------Error----------------------{"'DDLShipmentType' has a SelectedIndex which is invalid because it does not exist in the list of items.\r\nParameter name: value"}------------------------------------------------near cmb_ShipmentType.SelectedIndex = 0;i'm getting the selectedindex as -1 in the below codepublic void PopulateShipmentType(DropDownList cmb_ShipmentType) { string Sql = "select a,b from xxx where NUIsActive=1"; using (DataView Source = new DataView(objDBLib.ExecuteQuery(Sql).Tables[0])) { cmb_ShipmentType.DataSource = Source; cmb_ShipmentType.DataTextField = "a"; cmb_ShipmentType.DataValueField = "b"; cmb_ShipmentType.DataBind(); cmb_ShipmentType.SelectedIndex = 0; } } 解决方案 In your above Situation "Source" doesn't return any rows.So it can't set a value for SelectedIndex because there is nothing to select.Check your Table if there are any entries. 这篇关于SelectedIndex无效,因为它不存在于项列表中。参数名称的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!
10-19 06:10