I have an issue when trying to set up grouping in the code behind (vb.net) in that the data does not appear.
If I set up the grouping on the aspx page the records show up.
I have tried adding the datasource and databind before and after this code but I never get any records to appear.
I want to be able to dynamically turn certain grouping on or off depending on the user selection.
Can you tell me why the records are not showing up when I use the code behind page to create the grouping?
RadGrid1.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)
RadGrid1.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)
RadGrid1.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)
RadGrid1.MasterTableView.GroupByExpressions.Add(ge2)
End If
RadGrid1.DataSource = MyDataSource
RadGrid1.DataBind
If I set up the grouping on the aspx page the records show up.
I have tried adding the datasource and databind before and after this code but I never get any records to appear.
I want to be able to dynamically turn certain grouping on or off depending on the user selection.
Can you tell me why the records are not showing up when I use the code behind page to create the grouping?
RadGrid1.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)
RadGrid1.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)
RadGrid1.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)
RadGrid1.MasterTableView.GroupByExpressions.Add(ge2)
End If
RadGrid1.DataSource = MyDataSource
RadGrid1.DataBind