This is a migrated thread and some comments may be shown as answers.

GridClientSelectColumn

1 Answer 97 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Jack
Top achievements
Rank 1
Jack asked on 02 Jul 2008, 07:09 PM
Working with two controls: a CheckBoxList displays four group names, and a RadGrid displays individual users. When a check box is selected in the CheckBoxList, members of the corresponding group are removed from the RadGrid.  The sub procedure for binding the grid is included below. However, if an item is selected in the RadGrid before an item is selected in the CheckBoxList, the selected value is reset on databinding. Is there a way to persist the selected values?
Any help would be greatly appreciated!
Jack



Protected Sub bindGrid()

Dim GroupCount As Integer = groupCheckBoxList.Items.Count

Dim i As Integer

 

Dim WhereClause As String = ""

 

'looping with a variable rather than (groupCheckBoxList.Items.Count - 1) reduces overhead

 

For i = 0 To GroupCount - 1

'add selected items to comma deliminated string variable

 

If groupCheckBoxList.Items(i).Selected Then

 

If WhereClause <> "" Then WhereClause = WhereClause + ","

 

WhereClause = WhereClause + groupCheckBoxList.Items(i).Value.ToString

End If

 

Next

 

If WhereClause <> "" Then

 

'select command for when WhereClause has a value

 

SqlDataSource3.SelectCommand =

"SELECT * FROM [Users] WHERE group_id NOT IN (" & WhereClause & ")"

 

Else

 

'select command for when WhereClause is an empty string

 

SqlDataSource3.SelectCommand =

"SELECT * FROM [Users]"

 

End If

 

'set data source for RadGrid1

 

RadGrid1.DataSource = SqlDataSource3

'bind data to radGrid

 

RadGrid1.DataBind()

End Sub


1 Answer, 1 is accepted

Sort by
0
Princy
Top achievements
Rank 2
answered on 03 Jul 2008, 05:48 AM
Hi Jack,

Here is a help link which explains how to persist row selection on sorting, paging etc. Go through the link and alter the logic according to your scenario.
Persisting the selected rows on sorting/paging/filtering/grouping

Thanks
Princy.
Tags
Grid
Asked by
Jack
Top achievements
Rank 1
Answers by
Princy
Top achievements
Rank 2
Share this question
or