现象:
Item模板数据源采用视图,其中的出发地(StartLocation)列将原表中的id标示转换为对应的文字了;Edit模板中用RadioButtonList显示出发地显示为文字,值为其对应id。报错提示如题。
故障原因:
苦思三天,找到原因。Item模板切换到Edit模板时,会根据Item中的字段内容到RadioButtonList的值中寻找对应的选项,但是Item的字段内容为文字,而RadioButtonList值为id,找不到匹配的值。
解决方法:
将前台视图中的StartLocation字段定义为id,增加vStartLocation字段,用来显示文字内容。在FormView的Item模板中用vStartLocation字段显示,在Edit模板中将RadionButtonList的SelectedValue绑定到StartLocation。
视图:
SELECT dbo.aspnet_Users.UserName AS LastUpdateUserName, ……
dbo.Sys_Dictionary.dicValuesAS vLineType, dbo.wcxView_StartLocationFromSubcompany.scProvince ASvStartLocation,
Sys_Dictionary_1.dicValues AS vEndLocation,dbo.Product_TravelLines.StartLocation, dbo.Product_TravelLines.EndLocation,