关于绑定自动生成的下拉式菜单的错误

最近在做一个自动生成控件并更新内容的东东,但是出现了意想不到的错误。
在初始化页面的时候,我绑定了生成的控件(下拉菜单),并选择其中一个做为选中
值,在更新中(button_click事件中),我又绑定了该控件,并选择相同的一个结果。
这时会出现错误:DROPDOWNLIST不能有多个值被选中。。。

绑定控件事件:

dim _drpDownList as DropDownList
_drpDownList = new DropDownList
_drpDownList.cssClass = "myDropDownList"
_drpDownList.Items.Add(New ListItem("content1","1"))
_drpDownList.Items.Add(New ListItem("content2","2"))
webutil.DropDownList.SelectByValue(_drpDownList,"1")

运行后,我发现两次调用绑定事件后,在这个下拉菜单中会有四个值出现,也就是说
重复出现绑定的值,然后,我又在NEW 语句下添加了一句:
_drpDownList.Items.Clear()
结果还是不行,后来把这句移到紧挨着添加项的一行,才可以正确执行,并且
没有重复的项出现,问题解决了,但是还是很让人费解。

*************************************************************************************
 

Server Error in '/' Application.

Dynamic SQL generation for the UpdateCommand is not supported against a SelectCommand that does not return any key column information.

Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code.

Exception Details: System.InvalidOperationException: Dynamic SQL generation for the UpdateCommand is not supported against a SelectCommand that does not return any key column information.

Source Error:

An unhandled exception was generated during the execution of the current web request. Information regarding the origin and location of the exception can be identified using the exception stack trace below.

posted @ 2006-02-10 00:03  Henry Liu  阅读(583)  评论(0编辑  收藏  举报