Learn how to a build a cloud-first strategyRegister Now

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 210
  • 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

Featured Post

VIDEO: THE CONCERTO CLOUD FOR HEALTHCARE

Modern healthcare requires a modern cloud. View this brief video to understand how the Concerto Cloud for Healthcare can help your organization.

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