开发者

Programatically set OnSelectedIndexChanged for a ddl

a minor question but it's driving me nuts. I'm programatically generating about 50 DDLs based on a database schema (i.e. item 1 can do a,b,c item 2 can do d, e, a, etc etc).

If I was just writing the markup, I could specify:

asp:DropDownList OnSelectedIndexChanged="funTimes"

and be done with it, unfortunately, I'm just not sure how to set that programatically. I found a "SelectedIndexChanged" event开发者_Python百科, but I'm not sure what I need to return in terms of an event handler when all I want to do is set the method called. I realize I could write 50 methods:

ddl1_SelectedIndexChanged() ddl2_SelectedIndexChanged() etc etc

but that solution isn't terribly flexible, especially when I really only want the same method called. Is there a good way to accomplish what I'm trying to do here? Any input is greatly appreciated. Thanks.


You can set it from your code behind

DropDownList1.SelectedIndexChanged += new EventHandler ( funTimes ); 

You can set this from the Page_Load EventHandler or even from within the funTimes EventHandler.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜