C# Tutorials and offshore development in India
    Tutorials   Resources   Forum   Communities   Interview   Jobs   Projects   Offshore Development    
Silverlight Tutorials | Mentor | Code Converter | Articles | Code Factory | Computer Jokes | Members | Peer Appraisal | IT Companies | Bookmarks | Revenue Sharing |


Prizes & Awards
My Profile



Active Members
TodayLast 7 Days more...

New Feature: Community Sites: Create your own .NET community website and start earning from Google AdSense ! It's Free !




Handling SelectedIndexChanged event in DropDownList


Posted Date: 05 Dec 2005    Resource Type: Articles    Category: Web Applications

Posted By: Kuljit Singh Saini       Member Level: Bronze
Rating:     Points: 3



The code sample explains a way to handle a SelectedIndexChanged event in a DropDownList control

Steps to handle such events are listed below :

- Select AutoPostBack=true for DropDownList
- Specify function to call in OnSelectedIndexChanged="DropDownListSelect"
- Create the Public Function specified above
- Public Sub DropDownListSelect(ByVal sender As Object, ByVal e As System.EventArgs)
- get sender.Parent.anycontrol to manipulate

Example code follows:

The code immediately below is the .aspx page that displays a DropDownList control on a web page.

<ItemTemplate>

<asp:DropDownList ID="ddl1" Runat=server
AutoPostBack=True OnSelectedIndexChanged="DropDownListSelect">
</asp:DropDownList>
<asp:Label ID="lblStatus" Runat=server></asp:Label>

</ItemTemplate>


The sample code below shows VB.NET code that actually does the event handling.
When the event occurs, the page just displays a Hello in a Label control.


Public Sub DropDownListSelect(ByVal sender As Object, ByVal e As System.EventArgs)
Dim oDropDownList As DropDownList
Dim oLabel As Label
oDropDownList = CType(sender, DropDownList)
oLabel = oDropDownList.Parent.FindControl("lblStatus")
oLabel.Text = "Hello"
End Sub






Responses

Author: sreenu    19 Sep 2006Member Level: Bronze   Points : 0
Thank you for sharing the info..


Feedbacks      
Popular Tags   What are tags ?   Search Tags  
SelectedIndexChanged event  .  Handling SelectedIndexChanged event for DropDownList control  .  Handling SelectedIndexChanged event  .  

Post Feedback


This is a strictly moderated forum. Only approved messages will appear in the site. Please use 'Spell Check' in Google toolbar before you submit.
You must Sign In to post a response.
Next Resource: MVC design pattern using ASP.NET
Previous Resource: A better way of working with IE Webcontrols - Part II
Return to Discussion Resource Index
Post New Resource
Category: Web Applications


Post resources and earn money!
 
Related Resources



dotNet Slackers   BizTalk Adaptors    Web Design

doors in nj

Contact Us    Privacy Policy    Terms Of Use