• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 212
  • Last Modified:

how to set dropdown list value though a user control?

Hi Expert,

I have a test box and dropdown list on a user control. When user select dropdown list in another page which used this user control,  how to pass the value or index  to user contol?

code fragment in user control are here

Public Property FirstName() As String
        Get
            Return txtFName.Text
        End Get
        Set(ByVal value As String)
            txtFName.Text = value
        End Set
    End Property

Public Property Department() As String
        Get
            Return ddlDept.SelectedValue
        End Get
        Set(ByVal value As String)
            ddlDept.SelectedIndex = ddlDept.Items.IndexOf(ddlDept.Items.FindByValue(value))
      End Set
    End Property

Set first name works but department dropdown do not work.

Thanks in advance.

0
dshi15
Asked:
dshi15
1 Solution
 
sm394Commented:
something like that
Public Property SelectedValue() As String
        Get
            Return ddlDept.SelectedValue
        End Get
        Set(ByVal value As String)
            ddlDept.SelectedValue = value
        End Set
    End Property
0
 
dshi15Author Commented:
thanks,
I found out where is wrong,
Set(ByVal value As String)
            should be

Set(ByVal value As integer)
            ddlDept.SelectedValue = value
        End Set

I used deptId as value.

0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

Join & Write a Comment

Featured Post

Cloud Class® Course: Certified Penetration Testing

This CPTE Certified Penetration Testing Engineer course covers everything you need to know about becoming a Certified Penetration Testing Engineer. Career Path: Professional roles include Ethical Hackers, Security Consultants, System Administrators, and Chief Security Officers.

Tackle projects and never again get stuck behind a technical roadblock.
Join Now