Hi, I'm new to telerik controls. I'm trying to implement auto filter option in the telerik radgrid
<telerik:RadGrid ID="rgDashboard" ShowStatusBar="true" runat="server" AllowFilteringByColumn="true"
AutoGenerateColumns="False" AllowSorting="true" OnNeedDataSource="RadGrid1_NeedDataSource"
onsortcommand="rgDashboard_SortCommand" AllowPaging="true" PageSize="200">
<GroupingSettings CaseSensitive="false" />
<PagerStyle Mode="NumericPages" Position="TopAndBottom" ShowPagerText="false"> </PagerStyle>
<MasterTableView HeaderStyle-CssClass="goalGridHeader TableHeader" AllowFilteringByColumn="true">
<Columns>
<telerik:GridBoundColumn DataField="Center" HeaderText="Center Name"
AutoPostBackOnFilter="true" CurrentFilterFunction="Contains"
ShowFilterIcon="false" />
<telerik:GridBoundColumn DataField="Instructor" HeaderText="Instructor Name" AutoPostBackOnFilter="true" CurrentFilterFunction="Contains"
ShowFilterIcon="false" />
<telerik:GridBoundColumn DataField="CenterID" HeaderText="Center ID" AllowFiltering="false"/>
<telerik:GridTemplateColumn HeaderText="" AllowFiltering="false">
<ItemTemplate>
<asp:LinkButton ID="lnkEdit" Text="View" CssClass="btn btn-view btn-sm" OnClick="lnkEdit_OnClick" runat="server" />
</ItemTemplate>
</telerik:GridTemplateColumn>
</Columns>
</MasterTableView>
</telerik:RadGrid>
In code behind, I have filldata which binds the data to radgrid
private void filldata()
{
DataSet ds = new DataSet();
ds = gdh.GetCentersByFC(UserName, Admin, Email);
try
{
if ((ds != null) && (ds.Tables.Count > 0) && (ds.Tables[0].Rows.Count > 0))
{
lbldispBranch.Text = ds.Tables[0].Rows[0]["Branch"].ToString();
// lblLoggedInUser.Text = ds.Tables[0].Rows[0]["FCName"].ToString();
}
rgDashboard.DataSource = ds;
rgDashboard.DataBind();
}
catch (Exception ex)
{
GeneralHelper.LogFile(ex);
}
}
protected void rgDashboard_SortCommand(object sender, GridSortCommandEventArgs e)
{
filldata();
}
protected void RadGrid1_NeedDataSource(object sender, GridNeedDataSourceEventArgs e)
{
filldata();
}
I'm able to get the desired results, but getting below error after filter RadGrid1_NeedDataSource executes
Telerik.Web.UI.GridBindingException: You should not call DataBind in NeedDataSource event handler. DataBind would take place automatically right after NeedDataSource handler finishes execution.
at Telerik.Web.UI.RadGrid.DataBind()