<asp:DropDownList ID="deptddl1" runat="server" Height="38px" Style="margin-left: 33px" OnSelectedIndexChanged="deptddl1_SelectedIndexChanged" Width ="293px" AutoPostBack="true" ViewStateMode="Enabled" EnableViewState ="True" >
</asp:DropDownList>
<asp:DropDownList ID="designddl" runat="server" Height="28px" Width="297px">
<asp:ListItem>Select your designation</asp:ListItem>
</asp:DropDownList>
Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
If Not IsPostBack Then
Btnup.Visible = False
BindDept()
End If
end sub
Protected Sub BindDept()
Using con As New SqlConnection(constr)
Using cmd As New SqlCommand("select dept,deptid from vacancy ")
cmd.CommandType = CommandType.Text
cmd.Connection = con
con.Open()
deptddl1.DataSource = cmd.ExecuteReader()
deptddl1.DataTextField = "dept"
deptddl1.DataValueField = "deptid"
deptddl1.DataBind()
con.Close()
End Using
End Using
deptddl1.Items.Insert(0, New ListItem("-- Select--", "0"))
End Sub
Protected Sub deptddl1_SelectedIndexChanged(sender As Object, e As EventArgs)
dept = deptddl1.SelectedItem.ToString
Dim con As New SqlConnection
Dim s As String
Dim com As New SqlCommand
Dim dread As SqlDataReader
con = New SqlConnection(constr)
com = New SqlCommand()
con.Open()
com.Connection = con
Dim a As String = Request.QueryString("dept")
com.CommandText = "select design from pgentry where dept='" + dept + "' "
dread = com.ExecuteReader
While (dread.Read)
s = dread.Item("design")
Dim list As IList(Of String) = New List(Of String)(s.Split(New String() {","}, StringSplitOptions.None))
For Each element As String In list
designddl.Items.Add(element)
Next
End While
End Sub