-----------------------------------------------------------

New Message on BDOTNET

-----------------------------------------------------------
From: DotNetHunk
Message 13 in Discussion

hi all!!
im happy to say dat i have succeeded in getting a result finally!!code follows::

::::::::::::::::::::::::::::::Search button 
click:::::::::::::::::::::::::::::::::::::::

Private Sub search_Click(ByVal sender As System.Object, ByVal e As 
System.EventArgs) Handles search.Click
        Dim skill As String = DropDownList1.SelectedItem.Value
        Dim exp As Integer
        Dim result As String
        exp = CInt(DropDownList2.SelectedItem.Value)
        result = "emp_skill1 like '" + skill + "'"
        result += "or emp_skill2 like '" + skill + "'"
        result += "or emp_skill3 like '" + skill + "'"
        result += "or emp_skill4 like '" + skill + "'"
        result += "or emp_skill5 like '" + skill + "'"
        result += "and emp_experience_years>=" & exp
        dv.RowFilter = result

        If dv.Count > 0 Then
            DataGrid1.DataBind()
            lblMsg.Text = dv.Count & " row(s) found...."
            DataGrid1.Visible = True
        Else
            lblMsg.Text = "No records found.."
            DataGrid1.Visible = False
        End If
    End Sub
End Class

:::::::::::::::::::::::::::::::::::::page 
load:::::::::::::::::::::::::::::::::::::::::

 Private Sub Page_Load(ByVal sender As System.Object, ByVal e As 
System.EventArgs) Handles MyBase.Load
        'Put user code to initialize the page here
        conn = New SqlConnection("data source=localhost;user 
id=sa;password=;initial catalog=onlinejobapp")

        Try
            conn.Open()
            'Dim strDrop1, strDrop2 As String
            Dim da As SqlDataAdapter = New SqlDataAdapter("SELECT * from 
employerview", conn)
            Dim strdrop1, strdrop2 As String
            Dim cmd As New SqlCommand
            Dim dr As SqlDataReader
            da.Fill(ds, "employerview")
            ds.Tables(0).TableName = "employerview"
            dv = New DataView(ds.Tables(0))
            DataGrid1.DataSource = dv
            DataGrid1.DataBind()
            strDrop1 = "select * from skill where skill<>''"
            cmd = New SqlCommand(strdrop1, conn)
            dr = cmd.ExecuteReader
            DropDownList1.Items.Insert(0, New ListItem("--Skill--"))
            DropDownList1.DataSource = dr

            If Page.IsPostBack = False Then DropDownList1.DataBind()
            'DropDownList1.DataBind()

            dr.Close()
            strdrop2 = "select distinct emp_experience_years from emp_summary "
            Dim objDrop2 As New SqlCommand
            objDrop2 = New SqlCommand(strdrop2, conn)
            Dim objDR2 As SqlDataReader
            objDR2 = objDrop2.ExecuteReader
            DropDownList2.DataSource = objDR2

            If Page.IsPostBack = False Then DropDownList2.DataBind()
            'DropDownList2.DataBind()
            DropDownList2.Items.Insert(0, New ListItem("--Experience--"))
            objDR2.Close()
        Catch
        Finally
            If conn.State = ConnectionState.Open Then
                conn.Close()
                conn.Dispose()
            End If
        End Try
        
    End Sub

i have successfully populated the dropdownlists but a small problem is that i 
want to add a default value to dropdownlist like::: -------choose a 
skill----------
for this purpose,i used::
DropDownList1.Items.Insert(0, New ListItem("--Skill--"))
problem is where shud i place this piece of code??if placed in pageload below 
or above page.ispostback,then evrytime i perform a search,the ----choose a 
skill------ is adding up to the dropdownlist.i.e 4 times i press search,4 such 
default values r added.
this is not tricky nah guys??hope ull help me.
thanx for ur time
kiran k

-----------------------------------------------------------

To stop getting this e-mail, or change how often it arrives, go to your E-mail 
Settings.
http://groups.msn.com/bdotnet/_emailsettings.msnw

Need help? If you've forgotten your password, please go to Passport Member 
Services.
http://groups.msn.com/_passportredir.msnw?ppmprop=help

For other questions or feedback, go to our Contact Us page.
http://groups.msn.com/contact

If you do not want to receive future e-mail from this MSN group, or if you 
received this message by mistake, please click the "Remove" link below. On the 
pre-addressed e-mail message that opens, simply click "Send". Your e-mail 
address will be deleted from this group's mailing list.
mailto:[EMAIL PROTECTED]

Reply via email to