I am having an issue trying to set a default filter.
this is my grid if the user is of a certine type I want to filter the first grid and then not allow them to change the client.
this is the code behind
WHen I run the app as a user that should be filtered I get and error Expression expected on RadGrid1.MasterTable.Rebind().
what have I missed
this is my grid if the user is of a certine type I want to filter the first grid and then not allow them to change the client.
| <telerik:RadGrid ID="RadGrid1" AllowFilteringByColumn="true" runat="server" GridLines="None" |
| AllowPaging="true" AllowCustomPaging="true" AllowSorting="true" PageSize="5" OnPreRender="RadGrid1_PreRender" OnItemCreated="RadGrid1_ItemCreated" |
| Skin="Office2007" EnableViewState="false" PagerStyle-AlwaysVisible="true"> |
| <ClientSettings> |
| <ClientEvents OnCommand="RadGrid1_Command" OnHierarchyExpanding="RadGrid1_HierarchyExpanding" |
| OnHierarchyCollapsing="RadGrid1_HierarchyCollapsing" /> |
| </ClientSettings> |
| <MasterTableView HierarchyLoadMode="Client" ClientDataKeyNames="ClientID" PagerStyle-AlwaysVisible="true"> |
| <AlternatingItemStyle BackColor="#EEEEEE"></AlternatingItemStyle> |
| <RowIndicatorColumn> |
| <HeaderStyle Width="10px"></HeaderStyle> |
| </RowIndicatorColumn> |
| <ExpandCollapseColumn Visible="True"> |
| <HeaderStyle Width="10px"></HeaderStyle> |
| </ExpandCollapseColumn> |
| <Columns> |
| <telerik:GridBoundColumn DataField="ClientID" SortExpression="ClientID"/> |
| <telerik:GridBoundColumn SortExpression="ClientName" DataField="ClientName" HeaderText="Client Name" HeaderStyle-Width="100%" /> |
| </Columns> |
| <NestedViewTemplate> |
| <telerik:RadGrid ID="RadGrid2" AllowFilteringByColumn="true" Skin="Office2007" runat="server" |
| GridLines="None" AllowPaging="true" AllowSorting="true" PageSize="10" EnableViewState="false"> |
| <AlternatingItemStyle BackColor="#EEEEEE"></AlternatingItemStyle> |
| <ClientSettings> |
| <ClientEvents OnCommand="RadGrid2_Command" /> |
| </ClientSettings> |
| <MasterTableView ClientDataKeyNames="TradeConflictID, AdvisorBlotterID, APTransactionID"> |
| <Columns> |
| <telerik:GridBoundColumn SortExpression="AccountName" DataField="AccountName" HeaderText="Account Name" /> |
| <telerik:GridBoundColumn SortExpression="TradeDate" DataField="TradeDate" HeaderText="Trade Date" |
| DataType="System.DateTime" DataFormatString="{0:MM/dd/yyyy}" /> |
| <telerik:GridBoundColumn SortExpression="ABTransType" DataField="ABTransType" HeaderText="Transaction" /> |
| <telerik:GridBoundColumn SortExpression="Ticker" DataField="Ticker" HeaderText="Ticker" /> |
| <telerik:GridBoundColumn SortExpression="AccessPerson" DataField="AccessPerson" HeaderText="Access Person" /> |
| <telerik:GridBoundColumn SortExpression="APTradeDate" DataField="APTradeDate" HeaderText="Trade Date" |
| DataType="System.DateTime" DataFormatString="{0:MM/dd/yyyy}" /> |
| <telerik:GridBoundColumn SortExpression="APTransType" DataField="APTransType" HeaderText="Transaction" /> |
| <telerik:GridBoundColumn SortExpression="APTicker" DataField="Ticker" HeaderText="Ticker" /> |
| <telerik:GridCheckBoxColumn SortExpression ="Complete" DataField="Complete" HeaderText="Complete" DataType="System.Boolean" /> |
| <telerik:GridBoundColumn DataField="View" AllowFiltering="false" HeaderText="" AllowSorting="false" |
| UniqueName="View" Visible="true"> |
| </telerik:GridBoundColumn> |
| <telerik:GridBoundColumn DataField="Edit" AllowFiltering="false" HeaderText="" AllowSorting="false" |
| UniqueName="Edit" Visible="true"> |
| </telerik:GridBoundColumn> |
| </Columns> |
| </MasterTableView> |
| <PagerStyle AlwaysVisible="true" /> |
| </telerik:RadGrid> |
| </NestedViewTemplate> |
| </MasterTableView> |
| <PagerStyle AlwaysVisible="true" /> |
| <FilterMenu EnableTheming="True"> |
| <CollapseAnimation Type="OutQuint" Duration="200"></CollapseAnimation> |
| </FilterMenu> |
| </telerik:RadGrid> |
this is the code behind
| protected void RadGrid1_ItemCreated(object sender, Telerik.Web.UI.GridItemEventArgs e) |
| { |
| if (e.Item is GridFilteringItem) |
| { |
| if (Session["AdvisorClientID"] != null) |
| { |
| GridFilteringItem filterItem = (GridFilteringItem)e.Item; |
| filterItem.Visible = false; |
| } |
| } |
| } |
| protected void RadGrid1_PreRender(object sender, System.EventArgs e) |
| { |
| if (!Page.IsPostBack) |
| { |
| if (Session["AdvisorClientID"] != null) |
| { |
| RadGrid1.MasterTableView.FilterExpression = "([ClientID] = '" + Session["AdvisorClientID"].ToString() + "\' ) "; |
| GridColumn column = RadGrid1.MasterTableView.GetColumnSafe("ClientID"); |
| column.CurrentFilterFunction = GridKnownFunction.EqualTo; |
| RadGrid1.MasterTableView.Rebind(); |
| } |
| } |
| } |
WHen I run the app as a user that should be filtered I get and error Expression expected on RadGrid1.MasterTable.Rebind().
what have I missed