OnDataBound不会触发对ASP:DropDownList的静态ASP:ListItems的 [英] OnDataBound not fired for asp:DropDownList with static asp:ListItems

查看:405
本文介绍了OnDataBound不会触发对ASP:DropDownList的静态ASP:ListItems的的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个< ASP:DropDownList的> 女巫得到由静态列表项填写

 < ASP:DropDownList的... OnDataBound =handlerMethod>
    < ASP:ListItem的值=...文本=.../>
    < ASP:ListItem的值=...文本=.../>
    < ASP:ListItem的值=...文本=.../>
< / ASP:DropDownList的>

的问题是,当列表被填满 OnDataBound 事件不会被触发。我需要它来触发,从那些在下拉列表中的项目填补一些其他的数据。

该文件说:


  

这个方法通知任何数据绑定与控制相关的逻辑已经完成了服务器控件。


我的目光都集中在这个逻辑一词,这使得我的事情,我错过了在触发事件上的点

但如果是这样的话,我怎么能得到事件触发或者我可以用什么其他的事件,知道什么时候该列表已经完成beeing填补?


解决方案

通常情况下,这意味着您已删除了 AutoEventWireup =真或将其设置为false,并这就是为什么它没有连接最多的事件。

这也意味着,有什么不对的,它不再允许JavaScript的code运行。打开检查器(Chrome浏览器,Safari或Firefox中的Firebug - 不要依赖于IE浏览器开发者工具)。,看看是否有任何JavaScript错误,可能会导致页面停止

这也意味着 handlerMethod 未正确设置,最好的方法是删除HTML部分 OnDataBound =handlerMethod这种方法背后的code,然后转到设计视图中,打开活动的属性窗口,双击 OnDataBound ,它将正确添加事件。成立了一个破发点,并出现在调试与调试=在你的的web.config 文件真实。<运行/ p>

I have an <asp:DropDownList> witch gets filled by static list items.

<asp:DropDownList ... OnDataBound="handlerMethod">
    <asp:ListItem Value="..." Text="..." />
    <asp:ListItem Value="..." Text="..." />
    <asp:ListItem Value="..." Text="..." />
</asp:DropDownList>

The problem is that the OnDataBound event does not get triggered when the list is filled. I need it to trigger to fill some other data from the list items that are in the dropdown.

The documentation says:

This method notifies a server control that any data binding logic associated with the control has completed.

My eyes are on this "logic" word which makes me thing that i missed the point on when the event is triggered

But if that is the case, how can I get the event triggered or what other event can I use to know when the list has finished beeing filled?

解决方案

Normally this means that you have deleted the AutoEventWireup="true" or set it to false, and that's why it's not wiring up the event.

It can also mean that there is something wrong in the javascript that does not allow anymore code to run. Open the inspector (Chrome, Safari or Firebug in Firefox - Do not rely on IE Developer tools) and see if you have any javascript errors that can cause the page to stop.

It can also mean that the handlerMethod is not correctly set up, best way is to delete the html part OnDataBound="handlerMethod" and the code behind of this method, then go to design view, open the Properties window in the Events and double click the OnDataBound, it will add the event correctly. Set up a break point there and run in debug with debug="true" in your web.config file.

这篇关于OnDataBound不会触发对ASP:DropDownList的静态ASP:ListItems的的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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