Windows Develop Bookmark and Share   
 index > Windows Forms Data Controls and Databinding > modify gridview according to listbox
 

modify gridview according to listbox

hi all,

i have a gridview that will display all values when the page load. User can filter the data in the gridview by selecting multiple values ina fewlistboxes. However they do not necessarily need to select a value for each listboxes.

how can i create a dynamic selectcommand for multiple non-mandatory selection ?

i can't specify * as the default value as sql syntax does not allow 'in (*) '.

please help...

thanks!

minority80  Monday, May 22, 2006 1:41 AM

initially u give all the values ti the datagrid, through the DataView,

then on the SelectedValueChanged event of the ListBox Create Your Filter Criteria according to the values selected. and filter the View (DataView.RowFilter = "Filter Criteria")

for eg you FilterCriteria can be "AGE = 10 AND SEX = 'M'"

Rahul Saxena  Tuesday, May 23, 2006 1:51 PM

A siple solution would be having a default value fora ll the text boxesa nd use them in the query statement. And use the StringBuilder to write the query.

Hence, you can have the query with the default values from each ListBox or with the selected values from all/some/none of the ListBoxes

Ashraf Hameeda T  Monday, May 22, 2006 8:47 AM

initially u give all the values ti the datagrid, through the DataView,

then on the SelectedValueChanged event of the ListBox Create Your Filter Criteria according to the values selected. and filter the View (DataView.RowFilter = "Filter Criteria")

for eg you FilterCriteria can be "AGE = 10 AND SEX = 'M'"

Rahul Saxena  Tuesday, May 23, 2006 1:51 PM

thanks for the replies.

what i did was to change the datasource command and construct the sql query for each list box.

thanks for the alternatives.

minority80  Wednesday, May 24, 2006 7:33 AM

You can use google to search for other answers

Custom Search

More Threads

• datagrid
• Combobox selected value does not show correctly with master/detail combo binding..
• To calculate a person's age by date, month and year in VB 2008
• DataBinding Problem?
• Datagrid Cell Contents Double Click
• Datagridview
• "Index was out of range." error. Gridview.
• Problem with Data Sources
• windows forms dynamic controls
• Listview different in Vista and XP