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 !




Fill same values to all dropdownlist controls in a web form


Posted Date: 14 May 2008    Resource Type: Code Snippets    Category: ASP.NET WebForms
Author: kulanthaiveluMember Level: Gold    
Rating: Points: 10



The following code snippets will help you to fill the same values in all dropdonwlist in a form.

Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
If Not IsPostBack Then
FindDropDown(Page.Controls.GetEnumerator())
End If
End Sub
Public Sub FindDropDown(ByVal controls As IEnumerator)
Dim CtlType As String
Dim CtlName As String
Dim Ctl As Control
While controls.MoveNext()
If DirectCast(controls.Current, Control).HasControls() Then
FindDropDown(DirectCast(controls.Current, Control).Controls.GetEnumerator())
End If
CtlType = DirectCast(controls.Current, Control).GetType().Name
Ctl = DirectCast(controls.Current, Control)
CtlName = Ctl.ID
If CtlType = "DropDownList" Then
Call LoadDropDown(Ctl, "No")
End If
End While
End Sub
Private Sub LoadDropDown(ByVal DDL As DropDownList, ByVal SelVal As String)
Dim InsertList As ListItem
With DDL
InsertList = New ListItem()
InsertList.Text = "Yes"
InsertList.Value = "Y"
.Items.Add(InsertList)
InsertList = New ListItem()
InsertList.Text = "No"
InsertList.Value = "N"
.Items.Add(InsertList)
If SelVal = "No" Then
.SelectedValue = "N"
ElseIf SelVal = "Yes" Then
.SelectedValue = "Y"
End If
End With
End Sub

Regards,
Kulanthaivelu.V




Responses


No responses found. Be the first to respond and make money from revenue sharing program.

Feedbacks      
Popular Tags   What are tags ?   Search Tags  
(No tags found.)

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: Customvalidator control with FileUpload control for uploading only jpeg, jpg, or bmp file
Previous Resource: Image Preview (Javascript and DataRepeater)
Return to Discussion Resource Index
Post New Resource
Category: ASP.NET WebForms


Post resources and earn money!
 
Related Resources



dotNet Slackers   BizTalk Adaptors    Web Design


Contact Us    Privacy Policy    Terms Of Use