Thursday, November 10, 2011

Label to filter in GridTemlpateColumn

Problem: I want to filter an ASP label
"<asp:Label  runat="server" Text='<%# eval("AnyThing") %>' ></asp:Label>"
in Telerik GridTemplateColumn .Also I dont want Filter Icon to display and I Want "Contains" Filter Function.

Sloution: Just give DataField="DataFieldName" in GridTemplateColumn.The DataField Name which you are using to evaluate Label

Example:
<asp:Label ID="lblName" runat="server" Text='<%# eval("Name")></asp:Label>
Must be given to DataField e.g DataField="Name".
The Green Highlighted Text Is For Filter Icon To Hide and For Filtering With "Contains" 
The Aqua Highlighted  text is For Filtering a String From  Label

Yellow  Is Common For Both

Here Is The Sample Code:


<telerik:RadGrid ID="RadGrid1" runat="server" AutoGenerateColumns="False"   >
           <MasterTableView  AllowFilteringByColumn="True"  >
                    <Columns>
                             <telerik:GridTemplateColumn AllowFiltering="true"   AutoPostBackOnFilter="true" HeaderText="Name" datafield="Name" DataType="System.String"
ShowFilterIcon="false"   CurrentFilterFunction="Contains" UniqueName="Name" >
                                         <ItemTemplate>
                                                   <asp:Label ID="lblName" runat="server" Text='<%# eval("Name") %>'>
                                                   </asp:Label>
                                         </ItemTemplate>
                             </telerik:GridTemplateColumn>
                    </Columns>
           </MasterTableView>
</telerik:RadGrid>
               


No comments:

Post a Comment