This is a migrated thread and some comments may be shown as answers.

RadGrid FilterTemplate SelectedValue

1 Answer 14 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Frank
Top achievements
Rank 1
Frank asked on 25 Apr 2014, 06:39 PM
I have a grid on a screen that the user can filter using a RadComboBox in a FilterTemplate and everything works great.  I will persist this information so if the user leaves the screen and then comes back the will start with their last filter. 
The issue I am having is if for some reason a user eliminates the record that the grid was filter on.  If the user goes back to the page the screen errors because
SelectedValue='<%# Container.OwnerTableView.GetColumn("ClientName").CurrentFilterValue %>' is looking for a value that does not exist anymore.  How can I alter the code so that it would clear there previous filter.

1 Answer, 1 is accepted

Sort by
0
Shinu
Top achievements
Rank 1
answered on 28 Apr 2014, 10:15 AM
Hi Frank,

Please try setting the SelectedValue of RadComboBox not declaratively, but binding it the code behind:

C#:
protected void RadGrid1_ItemDataBound(object sender, GridItemEventArgs e)
{    
   if (e.Item is GridFilteringItem)
   {
     GridFilteringItem filterItem = (GridFilteringItem)e.Item;
     RadComboBox combo = (RadComboBox)filterItem.FindControl("RadComboBoxID");
     combo.SelectedValue = e.Item.OwnerTableView.GetColumn("ColumnUniqueName").CurrentFilterValue;
   }
}

Thanks,
Shinu
Tags
Grid
Asked by
Frank
Top achievements
Rank 1
Answers by
Shinu
Top achievements
Rank 1
Share this question
or