Get Help:Ask a Question in our Forums|Report a Bug|More Help Resources
Last post Feb 28, 2012 10:43 AM by thutaaung
Feb 27, 2012 10:06 PM|LINK
hope you are doing fine.
I have a datatable loaded from a database. I bind the datatable to a gridview on page_load. Now I want to filter the gridview by a user selection so I made a checkboxlist and wrote some code as follow at CheckBoxList1_SelectedIndexChanged
Dim selectedartist As String = CheckBoxList1.SelectedItem.ToString()
Dim dTable As DataTable = Session("dTable")
Dim dTablenew As New DataTable
Dim str As String = "Song_Artist ='" & selectedartist & "'"
dTablenew = dTable.Select(str).CopyToDataTable
GridView1.DataSource = dTablenew
With this code above, it can filter if there is only one selection on the checkboxlist. I try to loop the checkboxlist myself but always ended up in errors. Hope someone can help me out to make this work.
Thanks so much.
Feb 27, 2012 10:54 PM|LINK
You need to iterate thru all the items in the checkbox list and create a filter based on it...
Have a look at this link
Feb 28, 2012 10:43 AM|LINK
Seems like there is no straight forward answer to this. Thanks for the link. 4guysfromrolla is quite popular around developers. But I didn't know they have a tutorial on this. I will read through and hope it helps.