按钮Click事件触发DropDownList_SelectedIndexChanged事件,但我不想要它。 [英] Button Click event fires DropDownList_SelectedIndexChanged event but I don't want it.

查看:108
本文介绍了按钮Click事件触发DropDownList_SelectedIndexChanged事件,但我不想要它。的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述






我有两个下拉列表 - ddl1和ddl2以及一个按钮。

我选择一个值来自ddl1,它触发ddl1_selectedIndexChanged事件。

出现上述事件时,ddl1选择的值将转到WHERE子句中的SELECT语句中的数据库,以获取所需数据的一些行。

这个新数据表现在填充ddl2。

现在我从ddl2中选择一个值。

我按下按钮。

现在我想用button_click事件中的ddl2_selected值。

当我按下按钮时,ddl1_selectedIndexChanged事件意外触发并再次绑定ddl2,因此我松开了ddl2_selectedValue。



我的页面中没有使用AJAX或更新面板。

ASP.NET 4.0。

ddl1 - EnableViewState True,PostBack = True

ddl2 - EnableViewState True,PostBack = False



请帮帮我。

提前致谢。

Hi

I have two drop down lists - ddl1 and ddl2 and a button.
I select a value from ddl1 which fires ddl1_selectedIndexChanged event.
On occurance of abovesaid event, ddl1 selected value goes to database in a SELECT statement in WHERE Clause to fetch some rows of required data.
This new data table now populates ddl2.
Now I select a value from ddl2.
I press the button.
Now I want to use the ddl2_selected value in button_click event.
What happens is when I press the button, ddl1_selectedIndexChanged event fires unexpectedly and binds the ddl2 once again and hence I loose the ddl2_selectedValue.

I have not used AJAX or Update Panel in my page.
ASP.NET 4.0.
ddl1 - EnableViewState True, PostBack = True
ddl2 - EnableViewState True, PostBack = False

Please help me out.
Thanks in advance.

推荐答案

大家好,



我通过网上的几个博客解决了这个问题。

我在做什么是在asp面板中编写了这整套控件。

此面板的viewState属性设置为False。

尽快我将其更改为true,不需要的selectedindexchanged事件被抑制。



这让我了解了。 :)



但是,这是一种预感。

我还没知道为什么会发生这种情况?



非常欢迎解释。



@Anil:感谢关注。
Hi Everyone,

I resolved the issue by going through a couple of more blogs over net.
What I was doing was I wrote these entire set of controls in asp Panel.
The viewState property of this panel was set to False.
As soon as I changed it to true, the unwanted selectedindexchanged event got suppressed.

This got me through. :)

But, it was a hunch.
I did not yet got the reason why this happened ?

Explanations are most welcome.

@Anil: Thanks fot the concern.


这篇关于按钮Click事件触发DropDownList_SelectedIndexChanged事件,但我不想要它。的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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