I got a grid with with a template column whose DataType property is set to System.Boolean and DataField property set to a bool field in the datasource.
I want to have a dropdown to filter it, i am following the tutorials at http://tv.telerik.com/watch/aspnet/radgrid/radgrid-for-aspnet-filtering-with-dropdown-for-checkbox-column and http://www.telerik.com/help/aspnet-ajax/grid-filtering-for-gridchecboxcolumn.html
so in my code behind i have
It just does not work, it renders and even submits when an option is chosen from the dropdown but it does not filter. and i am unable to figure out why.
anyone?
thanks
<telerik:GridTemplateColumn HeaderText="Physical Count Date" HeaderStyle-HorizontalAlign="Center" DataType="System.Boolean" UniqueName="CountDate" DataField="HasCount" ItemStyle-Width="100" ItemStyle-HorizontalAlign="Left" AllowFiltering="true"> <ItemStyle CssClass="no-border" /> <ItemTemplate> <asp:Label ID="LabelDate" runat="server" Text='<%# ((bool)Eval("HasCount")) ? Eval("CountDate","{0:dd/MM/yyyy}") : "Not performed" %>'></asp:Label> </ItemTemplate>I want to have a dropdown to filter it, i am following the tutorials at http://tv.telerik.com/watch/aspnet/radgrid/radgrid-for-aspnet-filtering-with-dropdown-for-checkbox-column and http://www.telerik.com/help/aspnet-ajax/grid-filtering-for-gridchecboxcolumn.html
so in my code behind i have
protected void RadGrid2_ItemCreated(object sender, Telerik.Web.UI.GridItemEventArgs e) { if (e.Item is GridFilteringItem) { GridFilteringItem filteringItem = (e.Item as GridFilteringItem); filteringItem["CountDate"].Controls.Clear(); DropDownList ddList = new DropDownList(); ddList.AutoPostBack = true; ddList.SelectedIndexChanged += new System.EventHandler(ddList_SelectedIndexChanged); ddList.Items.Add(new ListItem("Clear filter", "Empty")); ddList.Items.Add(new ListItem("Show all counted", "True")); ddList.Items.Add(new ListItem("Show all not counted", "False")); if (Session["ddlSelValue"] != null) { ddList.Items.FindByValue((string)Session["ddlSelValue"]).Selected = true; } filteringItem["CountDate"].Controls.Add(ddList); } } protected void ddList_SelectedIndexChanged(object sender, System.EventArgs e) { DropDownList ddList = (DropDownList)sender; Session["ddlSelValue"] = ddList.SelectedValue; switch (ddList.SelectedValue) { case "True": RadGrid2.MasterTableView.FilterExpression = "([HasCount] = True) "; break; case "False": RadGrid2.MasterTableView.FilterExpression = "([HasCount] = False) "; break; case "Empty": RadGrid2.MasterTableView.FilterExpression = String.Empty; break; } foreach (GridColumn column in RadGrid2.MasterTableView.Columns) { column.CurrentFilterFunction = GridKnownFunction.NoFilter; column.CurrentFilterValue = String.Empty; } RadGrid2.MasterTableView.Rebind(); }It just does not work, it renders and even submits when an option is chosen from the dropdown but it does not filter. and i am unable to figure out why.
anyone?
thanks