I am using custom filter for my RadGrid (I wouldn't post the code here anymore) but my problem is, everything is working fine, but when I change page on the radGrid, it doesn't show anything , but when I click the filter button again it displays the results again
I tried putting this on my code:
protected void RadGrid1_PageIndexChanged(object sender, GridPageChangedEventArgs e)
{
RadGrid1.CurrentPageIndex = e.NewPageIndex;
DBcontrols.filterRadGrid();
DBcontrols.filterRadGridUsingRange();
RadGrid1.DataBind();
}
still No avail, how do I retain the Databind even when changing pages?
4 Answers, 1 is accepted

Please make sure you are binding the grid using Advanced Data-binding (Using NeedDataSource Event).
To perform complex operations such as Inserting, deleting, and updating records through custom edit forms Filtering, Sorting, Paging etc RadGrid must be bound using declarative data sources or through the NeedDataSource event. When using these, RadGrid can automatically accommodate the appropriate database operations without the need for you explicitly handle any sorting, paging, grouping, and so on.
Thanks,
Princy

I already included
SqlDataAdapter adapter = new SqlDataAdapter();
adapter.SelectCommand = new SqlCommand("SELECT * from dbo.transactFile", SQcon);
DataTable myDataTable = new DataTable();
SQcon.Open();
try
{
adapter.Fill(myDataTable);
}
finally
{
SQcon.Close();
}
Default._WelPage.RadGrid1.DataSource = myDataTable;
it is still not working


Dear Support team,
I want to retain ASP.NET RadGrid filter values after a page refresh or reload. I have created two functions, 'SaveGridFilters()' and 'RestoreGridFilters()'. 'SaveGridFilters()' sets the current values in the session, and 'RestoreGridFilters()' assigns the values to the filters. However, my issue is that the filter values are set in the current filter column, but the grid doesn't filter the rows. like when we entered the values and grid filter the rows. I have shared the server-side code. Please check and guide me. Thanks
protected void Page_Load(object sender, EventArgs e)
{
if (!Page.IsPostBack)
{
RestoreGridFilters();
}
}
protected void RadGrid1_NeedDataSource(object sender, GridNeedDataSourceEventArgs e)
{
try
{
RadGrid1.DataSource = ds.Tables[0];
}
catch
{ }
}
private void RestoreGridFilters()
{
if (Session["GridFilters"] != null)
{
Dictionary<string, string> filters = (Dictionary<string, string>)Session["GridFilters"];
RadGrid1.MasterTableView.FilterExpression = string.Empty;
foreach (var column in filters.Keys)
{
// RadGrid1.MasterTableView.GetColumn(column).CurrentFilterFunction = GridKnownFunction.Contains;
RadGrid1.MasterTableView.GetColumn(column).CurrentFilterValue = filters[column];
}
}
}
protected void RadGrid1_ItemCommand(object sender, GridCommandEventArgs e)
{
if (e.CommandName == RadGrid.FilterCommandName)
{
SaveGridFilters();
}
}
private void SaveGridFilters()
{
Dictionary<string, string> filters = new Dictionary<string, string>();
Session["GridFilters"] = null;
foreach (GridColumn column in RadGrid1.MasterTableView.RenderColumns)
{
if (!string.IsNullOrEmpty(column.CurrentFilterValue))
{
filters[column.UniqueName] = column.CurrentFilterValue;
}
}
Session["GridFilters"] = filters;
}
Hello Shakeel,
You can take advantage of the RadPersistence Framework to save the Grid setting including columns state. You can then save it somewhere (session, database, file, etc..) which can be restored later on demand.
Here are some articles explaining how to utilize the Persisteince Framework:
- Persisting Grid Settings
- Save and Restore the filters automatically
- Saving Grid Settings on a Per User Basis
See the list of supported controls for the Persistence Framework: Supported Controls
I hope this helps you out.
Kind regards,
Vasko
Progress Telerik