如何编写OnSelectedIndexChanged事件 [英] how to write OnSelectedIndexChanged event

查看:79
本文介绍了如何编写OnSelectedIndexChanged事件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

大家好,





我很困惑,如何写一个下拉列表的OnSelectedIndexChanged事件。



Hi guys,


I'm very confused, how to write OnSelectedIndexChanged Event of a dropdownlist.

SCENARIO:

---------------------------------------------------------------------------
|Repeater 1                                                                |
---------------------------------------------------------------------------
| ------------------------------------------------------------------------ |
| |Repeater 2                                                             ||
| |-----------------------------------------------------------------------||
| |-----------------------------------------------------------------------||
| |WEB USER CONTROL WITH: DROPDOWNLIST N A TEXTBOX  - [1]                 ||
| |-----------------------------------------------------------------------||
| |WEB USER CONTROL WITH: DROPDOWNLIST N A TEXTBOX  - [2]                 ||
| |-----------------------------------------------------------------------||
| |WEB USER CONTROL WITH: DROPDOWNLIST N A TEXTBOX  - [3]                 ||
| |-----------------------------------------------------------------------||
| -------------------------------------------------------------------------|
----------------------------------------------------------------------------





我已经填充了d下拉列表,它位于WebUserControl中,

但是,现在问题是,

如何编写OnSelectedIndexChanged事件。

所以,如果我在d下拉列表中选择任何值,它的文本也应该出现在那个WebUserControl的文本框中。



Plzzzz的家伙帮帮我。





谢谢



I have populated d dropdownlist which is in d WebUserControl,
but, now the problem is,
How to write its "OnSelectedIndexChanged" event.
So that, If i select any value in d dropdownlist, its text should also appear in
the textbox of that WebUserControl.

Plzzzz guys help me.


thanks

推荐答案

你的要求不明确,我想你想在转发器里面的Dropdown的OnSelectedIndexChanged事件



在上面的情况下,在转发器外添加你的下拉菜单并创建那个事件(只是点击之后,从那里切下该下拉列表并粘贴在Repeater的Itemtemplate内。
your requirement is not clear , i think you want OnSelectedIndexChanged event of the dropdown inside the Repeater

in the above case , add your dropdown outside the repeater and create that event (just click) after that cut that dropdown from there and paste inside Itemtemplate of the Repeater.


你可以在你的web用户控件中进行OnSelectedIndexChanged事件。

网络用户控制l你可以制作一个

you can make the OnSelectedIndexChanged event in your web user control.
In the web user control you can make a
public event Action<string>OnSelectedIndexChangedDropDownListEvent;



此事件可以由使用您的Web用户控件的页面订阅。

在Web用户中你在写OnSelectedIndexChanged的方法中控制:




This event can be subscribed to by the pages that uses your web user control.
in the web user control in the method for the OnSelectedIndexChanged you write:

if (OnSelectedIndexChangedDropDownListEvent!=null)
    OnSelectedIndexChangedDropDownListEvent(dropdownListNameHere.SelectedValue);



所以内部事件是通过OnSelectedIndexChangedDropDownListEvent发布到外部世界。


So the inner event is posted to the outside world via the OnSelectedIndexChangedDropDownListEvent.


protected void rptrSection1_Bound(object sender, RepeaterItemEventArgs e)
{
var ctl = e.Item.FindControl("ddlS1") as SDropDownList;
ctl.SelectedIndexChanged += new EventHandler(ddlS1_SelectedIndexChanged);
}

[code]....


这篇关于如何编写OnSelectedIndexChanged事件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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