I am trying to change grouping using code behind. I have a radgrid which depending on what the user chooses group by one element or group by two. I attempted to do this via the code below, however when I do this the radgrid never displays any records. I have tried to add a DataSource and Databind before and after this code but the grid never displays any records. If I hard code the grouping on the ASPX page the records will show up although I cannot change the grouping dynamically. Can you tell me what I am doing wrong in the code below that records would not display?
rgPhysician.MasterTableView.GroupByExpressions.Clear()
Dim ShowFacilities As CheckBox = ctlOptions.FindControl("cbShowFacilities")
If ShowFacilities.Checked Then
Dim ge1 As New Telerik.Web.UI.GridGroupByExpression
Dim gf1 As New Telerik.Web.UI.GridGroupByField
gf1.FieldName = "Facility"
gf1.HeaderValueSeparator = String.Empty
gf1.HeaderText = "Facility - "
ge1.SelectFields.Add(gf1)
rgPhysician.MasterTableView.GroupByExpressions.Add(ge1)
Dim ge2 As New Telerik.Web.UI.GridGroupByExpression
Dim gf2 As New Telerik.Web.UI.GridGroupByField
gf2.FieldName = "Name"
gf2.HeaderValueSeparator = String.Empty
gf2.HeaderText = " "
ge2.SelectFields.Add(gf2)
rgPhysician.MasterTableView.GroupByExpressions.Add(ge2)
Else
Dim ge2 As New Telerik.Web.UI.GridGroupByExpression
Dim gf2 As New Telerik.Web.UI.GridGroupByField
gf2.FieldName = "Name"
gf2.HeaderValueSeparator = String.Empty
gf2.HeaderText = " "
ge2.SelectFields.Add(gf2)
rgPhysician.MasterTableView.GroupByExpressions.Add(ge2)
End If
rgPhysician.MasterTableView.GroupByExpressions.Clear()
Dim ShowFacilities As CheckBox = ctlOptions.FindControl("cbShowFacilities")
If ShowFacilities.Checked Then
Dim ge1 As New Telerik.Web.UI.GridGroupByExpression
Dim gf1 As New Telerik.Web.UI.GridGroupByField
gf1.FieldName = "Facility"
gf1.HeaderValueSeparator = String.Empty
gf1.HeaderText = "Facility - "
ge1.SelectFields.Add(gf1)
rgPhysician.MasterTableView.GroupByExpressions.Add(ge1)
Dim ge2 As New Telerik.Web.UI.GridGroupByExpression
Dim gf2 As New Telerik.Web.UI.GridGroupByField
gf2.FieldName = "Name"
gf2.HeaderValueSeparator = String.Empty
gf2.HeaderText = " "
ge2.SelectFields.Add(gf2)
rgPhysician.MasterTableView.GroupByExpressions.Add(ge2)
Else
Dim ge2 As New Telerik.Web.UI.GridGroupByExpression
Dim gf2 As New Telerik.Web.UI.GridGroupByField
gf2.FieldName = "Name"
gf2.HeaderValueSeparator = String.Empty
gf2.HeaderText = " "
ge2.SelectFields.Add(gf2)
rgPhysician.MasterTableView.GroupByExpressions.Add(ge2)
End If