Click here to Skip to main content
15,909,953 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
got a huge problem here. I know that my query is not complete but i dont know what the exact function that i am looking for. As you see ive created a radiobuttonlist A-Z and i want my list box to be filtered according to what the selected value of my radiolist. My problem is that when I clicked a letter all the data composing of choosed letter a will be displayed on my list box where i just want the first letter of the data to be published. Sorry for my english and more power
note that filtering is the name of my radiolist
VB
Public Sub listcoursecode()
        Do While strsql = String.Empty
            strsql = "select * from [tblCourseTitle] where CourseCode like '%" & Trim(filtering.SelectedValue) & "%' Order by [CourseCode]Asc"
            Dim cmd As SqlCommand = New SqlCommand(strsql, cn)
            cn.Open()
            lbCourseCode.DataSource = cmd.ExecuteReader
            lbCourseCode.DataTextField = "CourseCode"
            lbCourseCode.DataValueField = "CourseTitle"
            lbCourseCode.DataBind()
        Loop
        cn.Close()
        strsql = String.Empty
    End Sub

    Protected Sub filtering_SelectedIndexChanged(ByVal sender As Object, ByVal e As System.EventArgs) Handles filtering.SelectedIndexChanged
        listcoursecode()
    End Sub
End Class
Posted

like '%" & Trim(filter
Remove the % symbol from your query.
% actually selects all words containing 'a'. If you remove it, all words containing the first character will be picked up.
 
Share this answer
 
Comments
janwel 14-Sep-11 23:38pm    
sir now all the data doesnt show up when i click on radio list. Why sir?
try with this

C#
strsql = "select * from [tblCourseTitle] where CourseCode like '" & Trim(filtering.SelectedValue) & "%' Order by [CourseCode]Asc"

remove only first % from query if you want to get data start from first character from A-Z
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900