的asp:DropDownList的错误:DropDownList1'具有的SelectedValue这是无效的,因为它不会在项目列表中存在 [英] asp:DropDownList Error: 'DropDownList1' has a SelectedValue which is invalid because it does not exist in the list of items

查看:116
本文介绍了的asp:DropDownList的错误:DropDownList1'具有的SelectedValue这是无效的,因为它不会在项目列表中存在的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个asp.net 2.0网站,与众多的asp:DropDownList控件。
DropDownList控件包含标准的信息城市,州,县等..信息。
除了标准的codeS该网站也有定制codeS的用户可以自行配置。
例如,一个动物的下拉可能包含值狗,猫,鱼,等...

I have a asp.net 2.0 web site with numerous asp:DropDownList controls. The DropDownList control contains the standard info city, state, county etc... info. In addition to the standard codes the site also has custom codes that the users can configure themselves. For example a animal dropdown may contain the values Dog, Cat, Fish, ect...

我从我如创建的SQL 2005表popluating将DropDownList TBL codeS

I am popluating the DropDownList from a SQL 2005 table that I created e.g. tblCodes

一切的伟大工程,用户可以使用众多的DropDownList控件从列表中选择要新增订单。

Everything works great and users are able to add orders using the numerous DropDownList controls to choose items from the list.

如果用户希望改变他们的定制下拉菜单中的一个问题occurrs。例如,一个用户想改变verbage
在动物类型的控制,从狗到K9。这是问题的开始。

The problem occurrs if a user wants to change one of their custom dropdowns. For example a user would like to change the verbage on a animal type control from Dog to K9. This is where the problem starts.

对于所有的新订单下拉正常工作。当用户检索的旧秩序
我得到了C#codebehind以下错误
'DropDownList1'具有的SelectedValue,因为它不在项目列表中存在这是无效的。

For all new orders the drop down works fine. When the user retrieved an old order I get the following error in the C# codebehind "'DropDownList1' has a SelectedValue which is invalid because it does not exist in the list of items."

这是怎么回事是旧秩序的狗和DropDownList中的数据库字段值不再有狗在其列表,因为用户把它改为K9。

What's happening is the old order has a database field value of Dog and the DropDownList no longer has Dog in its list since the user changed it to K9.

这是一个解决办法的任何想法?

有没有一种方法,使ASP:DROPDOWNLIST接受其列表中未接种项目?
难道还有其他的控制,我可以使用?

Any ideas on a workaround?
Is there a way to make the asp:DropDownList accept items not seeded in its list? Is there another control I could use?

推荐答案

我不知道这是同样的问题,但我也有类似的冠冕堂皇的问题,试图绑定一个DropDownList,我想在GridView遏制。当我环顾四周,我发现有很多人问类似的问题,但没有强大的解决方案。我看过你是否能拦截数据绑定等事件冲突的报告。我想大多数人,但我觉得couldn'f拦截或pre从而抢占错误的方式。

I'm not sure it's the same issue, but I had a similar sounding issue with trying to bind a DropDownList that I wanted to contain in a GridView. When I looked around I found a lot of people asking similar questions, but no robust solutions. I did read conflicting reports about whether you could intercept databinding, etc events. I tried most of them but I couldn'f find a way of intercepting or pre-empting the error.

我最终创造了DDL的一个子类,从那里黑客修复拦截错误。

I ended up creating a subclass of the ddl, intercepting the error from there hacking a fix.

不整洁,但它的工作对我的需要。我把我的博客的情况下,code了它的帮助。 链接文本

Not tidy but it worked for my needs. I put the code up on my blog in case it's of help. link text

这篇关于的asp:DropDownList的错误:DropDownList1'具有的SelectedValue这是无效的,因为它不会在项目列表中存在的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆